Link to home
Start Free TrialLog in
Avatar of NAORC
NAORC

asked on

Easy List Box Question - Urgent

In vb6 I want to do something to each individual item within a list box..

eg:

   for each item in listbox1.items
      'mess about with the contents of that line
   next item

I do not know the correct syntax though..

Help
ASKER CERTIFIED SOLUTION
Avatar of jmundsack
jmundsack
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of justchat_1
justchat_1

Dim i as integer 'better coding
For i = 0 To ListBox1.ListCount - 1
    '-- Your stuff--
Next i
If you are going to be removing any, however, you're going to want to decrement i instead:
For i = ListBox1.ListCount - 1 to 0 step -1

Private Sub Form_Load()
Dim i As Long        'even better coding, because a long is faster as an integer!
For i = 9 To 15      'first fill the list with random data
   List1.AddItem i
Next

For i = 0 To List1.ListCount - 1
   List1.List(i) = "item: " & CStr(i)     'then assign new data
Next
End Sub