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


  • 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!



    Keenan Stewart (

    Learning Advisor,

    Microsoft Certified Technical Education Center

    Novell Authorized Online Training Provider


  • To use code to select all items:

    For I = 1 to List1.ListCount - 1

    List1.Selected(I) = True


    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:


    End If


    To score all items:

    For I = 0 to List1.ListCount - 1

    'retrieve item as above, using:



    Hope this helps!

Sign In or Register to comment.

Howdy, Stranger!

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