2-
Private Sub TextBox1_TextChanged(...) Handles TextBox1.TextChanged
Dim srchWord As String = TextBox1.Text.Trim
If srchWord.Length = 0 Then Exit Sub
Dim wordIndex As Integer
wordIndex = ListBox1.FindStringExact(srchWord)
If wordIndex >= 0 Then
ListBox1.TopIndex = wordIndex
ListBox1.SelectedIndex = wordIndex
Debug.WriteLine("EXACT MATCH AT INDEX = " & wordIndex.ToString & vbCrLf & _
"MATCH = " & ListBox1.Items(wordIndex).ToString)
Else
wordIndex = ListBox1.FindString(srchWord)
If wordIndex >= 0 Then
ListBox1.TopIndex = wordIndex
ListBox1.SelectedIndex = wordIndex
Debug.WriteLine("NEAR MATCH AT INDEX = " & wordIndex.ToString & vbCrLf & _
"MATCH = " & ListBox1.Items(wordIndex).ToString)
Else
Debug.WriteLine("Item " & srchWord & " is not in the list")
End If
End If
End Sub