I am trying to filter a ListBox based on the presence of a string. Basically, if there is a ListItem that doesn\'t contain the string then I want to remove all ListItems that do
Based on balpha's help above, this is what I ultimately did:
Dim StringPresent As Boolean = False
Dim Item As ListItem
For Each Item In CtheList.Items
If Item.Text.IndexOf("W:") = -1 Then
StringPresent = True
Exit For
End If
Next
If StringPresent = True Then
Dim i As Integer
For i = CtheList.Items.Count - 1 To 0 Step -1
If CtheList.Items.Item(i).Text.IndexOf("W:") > -1 Then
CtheList.Items.RemoveAt(i)
End If
Next i
End If