Highlights
All Snippets
Top 100 Snippets
Librarians
gbCodeLib

By Language
VB6
JavaScript
Perl
HTML
SQL
Java
DOS

GBIC >> Source Code >> Visual Basic >> Snippet

Listbox - use API for fast search


Private Declare Function SendMessageString Lib "user32" _
    Alias "SendMessageA" _
   ( ByVal hwnd As Long , _
    ByVal wMsg As Long , _
    ByVal wParam As Long , _
    ByVal lParam As String ) As Long
Private Const LB_FINDSTRING = &H18F
Private Const LB_FINDSTRINGEXACT = &H1A2

Dim iIndex As Long
Dim FindString As String
FindString = "FindThis"
iIndex = SendMessageString(List1.hwnd, LB_FINDSTRINGEXACT, - 1, FindString)
If iIndex > - 1 Then List1.ListIndex = iIndex