|
|
Title | Quickly locate an item in a ListBox that begins with a certain substring |
Keywords | ListBox, find, SendMessage |
Categories | API, Controls |
|
|
Use the SendMessage API function to send the ListBox a LB_FINDSTRING message. SendMessage returns the item's index in the list.
|
|
Private Sub cmdSearch_Click()
Dim item_index As Long
item_index = SendMessage(List1.hwnd, _
LB_FINDSTRING, -1, ItemText.Text)
If item_index < 0 Then
MsgBox "Item not found"
Else
MsgBox "Item " & Format$(item_index)
End If
End Sub
|
|
|
|
|
|