Login | Register   
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Visual Basic
Expertise: Intermediate
Aug 20, 1997

Finding a String in a Combo Box

The CBFindString()procedure searches for a string in a combo box by using 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 
Paul D. Sheriff
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap