SearchXBox




Public Sub CheckList(TypeOfList As String, _
Optional MyCombo As ComboBox, Optional _
MyListBox As ListBox, Optional MyString _
As String)
Dim Count As Integer
Select Case UCase(TypeOfList)
Case "COMBOBOX"
With MyCombo
For Count = 0 To .ListCount - 1
If UCase(.Text) = UCase(.List(Count) _
Then Exit Sub
Next
.AddItem(.Text)
End With

Case "LISTBOX"
With MyListBox
For Count = 0 To .ListCount - 1
If UCase(MyString) = _
UCase(.List(Count)) Then Exit Sub
Next
.AddItem(MyString)
.Selected(Count) = True
End With
End Select
End Sub

'example calls For this Function

Call CheckList("combobox",combo1)
Call CheckList("listbox",,list1,"Search 4 me")
'Note: To search a listbox you must leave a space

'between "listbox" and the name of the listbox

'and you have To include the String to search 4











( searchxbox.html )- by Paolo Puglisi - Modifica del 17/12/2023