0

I am attempting 2 separate ListBoxes for listing Offline and Online servers. The box refreshes every 3 seconds, and I need to be able to go through each item and get its text and index.

What can I do for this?

I've tried creating a For loop based on ListBox.Items but was unsuccessful.

1
  • 1
    Can you show with a little code what you have tried already?
    – user1693593
    Oct 6, 2012 at 1:21

2 Answers 2

8

You would probably want to use something along these lines:

For l_index As Integer = 0 To MyListBox.Items.Count - 1
    Dim l_text As String = CStr(MyListBox.Items(l_index))
Next
0

Try this classic method:

     For i = 0 To ListBox1.Items.Count - 1
        ListBox1.SelectedIndex = i
        MsgBox("text: " & ListBox1.Text & "index: " & i)
    Next

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.