by Mark Compton (1 Submission)
Category: Miscellaneous
Compatability: Visual Basic 3.0
Difficulty: Advanced
Date Added: Wed 3rd February 2021
Rating:
(7 Votes)
Locate an entry in combo or listbox using API call, rather than looping through all entries.
'Declarations
Public Const LB_FINDSTRING = &H18F
Public Const LB_FINDSTRINGEXACT = &H1A2
Public Const CB_FINDSTRING = &H14C
Public Const CB_FINDSTRINGEXACT = &H158
Declare Function SendMessageByString& Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As String)
'Functions
Function InList(sStringToFind as string, lstListBox As ListBox) As Boolean
InList = SendMessageByString(lstListBox.hwnd, LB_FINDSTRING, -1, sStringToFind) >= 0
End Function
Function InCombo(sStringToFind, cbCombo As ComboBox) As Boolean
InCombo = SendMessageByString(cbCombo.hwnd, CB_FINDSTRING, -1, sStringToFind) >= 0
End Function