Loop through listbox [solved]

Posts 1–6 of 6 · Page 1 of 1
Loop through listbox [solved]
ok so i want to "restart a listbox" what i mean is once it reaches the last item in the listbox i want it to go back to the beginning how would i do this? Thanks
I don't understand. Are you trying to clear it?
ListBox1.Items.Clear
Quote Originally Posted by master131 View Post
I don't understand. Are you trying to clear it?
ListBox1.Items.Clear
I am sorry I am not trying to clear it so I will try to describe it better. Ok so I have a listbox running off of a loop so the selected index keeps changing (The code for it to change:
Code:
listbox1.selectedindex +=1
) once it reaches the end the program crashes. So i was wondering how to make it go to
Code:
listbox1.selectedindex = 0
or the beginning of the the listbox once it reaches the end of the listbox.

I can try to re reword it if you still don't understand.
[highlight=vb.net]
If ListBox1.SelectedIndex = ListBox1.Items.Count - 1 Then
ListBox1.SelectedIndex = 0
Else
ListBox1.SelectedIndex += 1
End If
[/highlight]
Thanks that worked just fine
Marked solved then.
Posts 1–6 of 6 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Need help?