![]() ![]() | ||
You want to loop over the items in your list box to find out if a particular item is in the list-but you need to know how many items are in the list box in order to set up the loop. How can you set up the loop?
You can use the Items.Count value to determine how many items are in a list box. Here's an example where I'm displaying each item in a list box in a message box, one by one in a loop:
Private Sub Button1_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles Button1.Click Dim intLoopIndex As Integer For intLoopIndex = 0 To ListBox1.Items.Count - 1 MsgBox(ListBox1.Items(intLoopIndex)) Next End Sub
![]() ![]() | ||