1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
| Private Sub TextBoxRecherche_Change()
Dim FILTRE As String
Dim i As Long, j As Long
Dim resultatTrouve As Boolean
With Me
.ListBoxResultats.Clear
' Définit le filtre en ignorant la casse
FILTRE = "*" & LCase(TextBoxRecherche.Text) & "*"
For i = 0 To .ListBox1.ListCount - 1
For j = 0 To .ListBox1.ColumnCount - 1
If LCase(.ListBox1.List(i, j)) Like FILTRE Then
.ListBoxResultats.AddItem .ListBox1.List(i, 0)
.ListBoxResultats.List(.ListBoxResultats.ListCount - 1, 1) = .ListBox1.List(i, 1)
.ListBoxResultats.List(.ListBoxResultats.ListCount - 1, 2) = .ListBox1.List(i, 2)
.ListBoxResultats.List(.ListBoxResultats.ListCount - 1, 3) = .ListBox1.List(i, 3)
.ListBoxResultats.List(.ListBoxResultats.ListCount - 1, 4) = .ListBox1.List(i, 4)
' Sélectionne le premier résultat trouvé dans ListBox1
If Not resultatTrouve Then
.ListBox1.ListIndex = i
resultatTrouve = True
End If
Exit For
End If
Next j
Next i
End With
End Sub |
Partager