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.
Original Author: Mark Compton
Code
'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
Loading Comments ...
Comments
No comments have been added for this post.
You must be logged in to make a comment.