by Gabriel Tavares de Oliveira Castellani (5 Submissions)
Category: Custom Controls/Forms/Menus
Compatability: Visual Basic 5.0
Difficulty: Unknown Difficulty
Originally Published: Sat 3rd June 2006
Date Added: Mon 8th February 2021
Rating: (1 Votes)
Searches for the 1st occurrence (begining, middle or end) of a partial text in a ComboBox/ListBox. Returns Listindex. Procura pela 1a
API Declarations
NoInicio = 0 'In the beginning of the entry Ex.: Entry=CONSTANTINE; Text=CONST
NoMeio = 1 'In the middle Ex.: Entry=CONSTANTINE; Text=TANT
NoFim = 2 'In the end Ex.: ENTRY=CONSTANTINE; Text=INE
End Enum
' Função BuscaCombo
' Gabriel Tavares de Oliveira Castellani
' Retorna o listindex de uma entrada de Combo que contenha
' a string TEXTO
Function BuscaCombo(ByVal Combo As Control, Optional ByVal Texto As String = "", Optional ByVal Onde As enumBuscaCombo = 0) As Integer
Dim i As Integer
BuscaCombo = -1
If Texto = "" Then Texto = Combo.Text
Select Case Onde
Case 0
For i = 0 To Combo.ListCount - 1
If UCase$(Left$(Combo.List(i), Len(Texto))) = UCase$(Texto) Then
BuscaCombo = i
Exit For
End If
Next
Case 1
For i = 0 To Combo.ListCount - 1
If InStr(UCase$(Combo.List(i)), UCase$(Texto)) > 0 Then
BuscaCombo = i
Exit For
End If
Next
Case 2
For i = 0 To Combo.ListCount - 1
If UCase$(Right$(Combo.List(i), Len(Texto))) = UCase$(Texto) Then
BuscaCombo = i
Exit For
End If
Next
End Select
End Function
No comments have been posted about Searches for the 1st occurrence (begining, middle or end) of a partial text in a ComboBox/ListBox. . Why not be the first to post a comment about Searches for the 1st occurrence (begining, middle or end) of a partial text in a ComboBox/ListBox. .