You could also do this.
The second For/Next loop in the FindCB sub allows you to do the search again from the beginning after all the entries have been found. If you want to be able to search a second time before all the matches have been found you'll need to do that code someplace else.Code:Option Explicit Private Sub Command1_Click() FindCB Combo1, Text1.Text End Sub Private Sub Form_Load() Combo1.AddItem "MB489LE/" Combo1.AddItem "MB489XE" Combo1.AddItem "MB489FD" Combo1.AddItem "MC2341" Combo1.AddItem "XDMD42" Combo1.AddItem "XDMD41" Combo1.AddItem "KCLSISD" End Sub Private Sub FindCB(obj As Object, TextToFind As String) Dim lngIndex As Long Combo1.ListIndex = -1 For lngIndex = 0 To Combo1.ListCount - 1 If If InStr(1, UCase(Combo1.List(lngIndex)), UCase(Text1.Text)) _ And Combo1.ItemData(lngIndex) <> 1 Then Combo1.ListIndex = lngIndex Combo1.ItemData(lngIndex) = 1 Exit Sub End If Next For lngIndex = 0 To Combo1.ListCount - 1 Combo1.ItemData(lngIndex) = 0 Next End Sub




Reply With Quote