Currently I am able to use a texbox to search through the listbox only when the multiselect property is set to none. But when I change the property to simple or extended my function doesn't work. Please see below
Function
Calling the function
I also tried another method but neither work when the multi select property is not none. I can't search at all.
Any Ideas??
Function
Code:
Public Function CheckListbox(strPass As String, lstPersons As ListBox)
Dim intCurrIndex As Integer
Dim intStringLen As Integer
intStringLen = Len(strPass)
For intCurrIndex = 0 To lstPersons.ListCount - 1
If Left$(lstPersons.ItemData(intCurrIndex), intStringLen) = strPass Then
Exit For
End If
Next intCurrIndex
lstPersons = lstPersons.ItemData(intCurrIndex)
End Function
Code:
Private Sub abSearchtbox_KeyPress(KeyAscii As Integer)
Select Case KeyAscii
Case Asc(" ") To Asc("z")
strStringTyped = Me.abSearchtbox.Text & Chr(KeyAscii)
Case 8
If strStringTyped > "" Then
strStringTyped = Left$(strStringTyped, Len(strStringTyped) - 1)
End If
End Select
CheckListbox strStringTyped, Me.allAddressBooklbox
End Sub
Any Ideas??
Comment