Ok, I'm looping through a Filelistbox doing stuff. Everytime I loop through, I want my label to display the index of the file it's on. This doesn't seem to work:VB Code:
lblcurrent.caption = File1.ListIndex
It always returns a -1
Printable View
Ok, I'm looping through a Filelistbox doing stuff. Everytime I loop through, I want my label to display the index of the file it's on. This doesn't seem to work:VB Code:
lblcurrent.caption = File1.ListIndex
It always returns a -1
ListIndex shows which one is clicked. If your just looping, then do something like:Quote:
Originally posted by hipopony66
Ok, I'm looping through a Filelistbox doing stuff. Everytime I loop through, I want my label to display the index of the file it's on. This doesn't seem to work:VB Code:
lblcurrent.caption = File1.ListIndex
It always returns a -1
VB Code:
For i = 1 To File1.ListCount 'do whatever here Label1 = File1.List(i) 'do whatever here Next
That gives the listitem not the index value
For i = 0 to File1.Listcount-1
Label1=i
next
i will always = the index of the listbox.
You'll have to add a DoEvents or lbl.Refresh statement in the loop or you'll never see the update in the label.