Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
 
 
 
 
 
 
 
Old Pages
 
Old Index
Site Map
What's New
 
Books
How To
Tips & Tricks
Tutorials
Stories
Performance
Essays
Links
Q & A
New in VB6
Free Stuff
Pictures
 
 
 
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-2003 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated