Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
MSDN Visual Basic Community
 
 
 
 
 
TitleQuickly locate an item in a ListBox that begins with a certain substring
KeywordsListBox, find, SendMessage
CategoriesAPI, 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
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated