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
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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
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
For i = 0 To ListBox1.ListCount - 1
'-- Your stuff--
Next i