Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

listbox

I've just finished my first VB course. I'm now trying to write programs for my junior high students for the fall. I'm using VB 6 Pro. I've got a list box set up that stores the answers they have written in a text box. I've coded a score button that will give them a score out of ten in a label. My problem is that they must first click each item in the list box for the score command button to function. Is there a way to code it such that the items entered into the listbox are automatically clicked? Or is there another option

besides a click event that will accomplish the same goals for the listbox?

Julian Hudson


Comments

  • Hi there Julian,


    I believe that you could use the KeyDown or KeyUp events of the ListBox control to perform validation criteria. If they must enter a string of characters to be validated, have a message stating that they must press the enter key to validate the material. When the Enter key is pressed, simply validate the material. You can find more information on the KeyDown and KeyUp event by searching for these events in the Visual Basic Books Online.


    There are also a number of other functions that you can use, that belong to the ListBox control. Place a list box on the form, and then proceed to the code window. Select your ListBox from the General drop down box, as you will then be presented with all of the functions that are available for the list box control.


    I hope that this information helps, Julian. I wish you the best of luck in all your programming ventures!


    Sincerely,

    Keenan


    Keenan Stewart (keenan_stewart@scholars.com)

    Learning Advisor, http://www.scholars.com


    Microsoft Certified Technical Education Center

    Novell Authorized Online Training Provider


    URL:http://www.scholars.com

  • To use code to select all items:


    For I = 1 to List1.ListCount - 1

    List1.Selected(I) = True

    Next


    To score only selected items:


    For I = 0 to List1.ListCount - 1

    If List1.Selected(I) Then

    'Item was selected, process it

    'retrieve item using:

    'List1.List(I)

    End If

    Next


    To score all items:


    For I = 0 to List1.ListCount - 1

    'retrieve item as above, using:

    'List1.List(I)

    Next


    Hope this helps!


  • Chris BrownChris Brown USAMember Posts: 4,496 ✭✭

    __ // http://forcoder.org // free video tutorials and ebooks about | Scratch, PL/SQL, Visual Basic .NET, Assembly, Ruby, Python, C, JavaScript, Objective-C, Swift, Perl, Java, Delphi, C#, PHP, R, Go, C++, Visual Basic, MATLAB Transact-SQL, Prolog, COBOL, SAS, Awk, Logo, D, Bash, Erlang, Clojure, FoxPro, Alice, Lua, Fortran, Kotlin, ML, Scheme, Scala, Dart, Ada, Apex, LabVIEW, Crystal, ABAP, Rust, Hack, Julia, VBScript, F#, Lisp | _

Sign In or Register to comment.