Locate Entry in List/Combo using API, no looping
Locate an entry in combo or listbox using API call, rather than looping through all entries.
Rate Locate Entry in List/Combo using API, no looping
(7(7 Vote))
'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
Locate Entry in List/Combo using API, no looping Comments
No comments yet — be the first to post one!
Post a Comment