I have a multiselect Listbox on a Form. I need to iterate through this listbox and do something with all of the items that have been selected. Nothing I've tried has worked. Here is my lastest attempt.
vb.net Code:
  1. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  2. Dim item As Object
  3.   For i As Integer = ListBox1.Items.Count - 1 To 0 Step -1
  4.     If ListBox1.SelectedItems(i) = True Then
  5.        'do something with them
  6.     End If
  7. Next
  8.  
  9. End Sub
So, how do I go through the entire listbox and do my thing what all of the items that have been selected?