I think API function is the faster solution to search a string in ListBox or ComboBox. Below just a example how I did it.
Code:
Option Explicit
'NOTE:
'Please change the lParam Datatype from Long to Any
'Else the SendMessage API will not function correctly.
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
'For ComboBox
Private Const CB_FINDSTRING = &H14C
'For List View
Private Const LB_FINDSTRING = &H18F
Dim xOpt%
Private Sub Command1_Click()
Select Case xOpt
Case 0 'ComboBox Serach
Combo1.ListIndex = SendMessage(Combo1.hwnd, CB_FINDSTRING, -1&, ByVal CStr(Text1.Text))
Case 1 'ListBox Search
List1.ListIndex = SendMessage(List1.hwnd, LB_FINDSTRING, -1&, ByVal CStr(Text1.Text))
End Select
End Sub
Private Sub Form_Load()
With Combo1
.AddItem "Computer"
.AddItem "Screen"
.AddItem "Modem"
.AddItem "Printer"
.AddItem "Scanner"
.AddItem "Sound Blaster"
.AddItem "Keyboard"
.AddItem "CD-Rom"
.AddItem "Mouse"
.ListIndex = 0
End With
With List1
.AddItem "Computer"
.AddItem "Screen"
.AddItem "Modem"
.AddItem "Printer"
.AddItem "Scanner"
.AddItem "Sound Blaster"
.AddItem "Keyboard"
.AddItem "CD-Rom"
.AddItem "Mouse"
End With
End Sub
Private Sub Option1_Click()
xOpt = 0
End Sub
Private Sub Option2_Click()
xOpt = 1
End Sub
By the way, jmatello can I have a copy you the source that you mention? because current I working with binary data file and writing a faster text search routine to searcha particular text under WinCE platform.
Thanks jmatello.