VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Locate Entry in List/Combo using API, no looping

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.

Rate Locate Entry in List/Combo using API, no looping

'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

Download this snippet    Add to My Saved Code

Locate Entry in List/Combo using API, no looping Comments

No comments have been posted about Locate Entry in List/Combo using API, no looping. Why not be the first to post a comment about Locate Entry in List/Combo using API, no looping.

Post your comment

Subject:
Message:
0/1000 characters