devxlogo

Finding a String in a Combo Box

Finding a String in a Combo Box

The CBFindString()procedure searches for a string in a combo box byusing the SendMessage() API function to find a specific entry in the list.This is much more efficient than searching using VB code:

 Declare Function SendMessage Lib "User" _ (ByVal hWnd As Integer, ByVal wMsg As Integer, _ ByVal wParam As Integer, lParam As Any) As Long Sub CBFindString (ctlEdit As Control, _ sSearch As String) Dim lPos As Long Const CB_FINDSTRING = &H40C lPos = SendMessage(ctlEdit.hWnd, CB_FINDSTRING, _ 0, ByVal sSearch) If lPos >= 0 Then ctlEdit.ListIndex = lPos End If End Sub 
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist