Here goes, this binary search should find you as fast as possible, remove the lcases if you want case sensistive search.
Code:Private Sub Text1_Change() List1.ListIndex = BinarySearch(Text1.Text, List1) End Sub Function BinarySearch(Byval str As String, list As ListBox) Dim x&, l&, temp$ str = lcase(str) l = List1.ListCount / 2 x = l Do temp = lcase(list.list(x)) If str = temp Then Exit Do ElseIf str > temp Then l = l / 2 x = x + l Else l = l / 2 x = x - l End If Loop While l BinarySearch = x End Function





Reply With Quote