Private Sub ListBox1_Click()
Dim n As Variant, x$, s, a$, nn%, i%
TextBox2 = P(ListBox1) 'propriété BoundColumn = 1
TextBox2.SetFocus
n = InStr(TextBox2, TextBox1)
If n Then
TextBox2.SelStart = n - 1
TextBox2.SelLength = Len(TextBox1)
ElseIf OptionButton1 Then 'recherche s'il y a des caractères génériques
x = Replace(TextBox1, """", """""") 'remplacement des guillemets
If CheckBox1 Then x = Replace(x, "*", Chr(1))
If CheckBox2 Then x = Replace(x, "?", "~?")
s = Split(x, "*")
x = Replace(x, Chr(1), "~*")
a = P(ListBox1).Address
n = Evaluate("SEARCH(""" & x & """," & a & ")")
If IsError(n) Then GoTo 1 'sécurité
nn = n
For i = 1 To UBound(s)
nn = Evaluate("SEARCH(""" & s(i) & """," & a & "," & nn + Len(Replace(s(i - 1), "~?", "?")) & ")")
Next
TextBox2.SelStart = n - 1
TextBox2.SelLength = nn + Len(Replace(s(UBound(s)), "~?", "?")) - n
Else
1 TextBox2.SelStart = 0
ListBox1.SetFocus
End If
Label4 = "Nombre de caractères : " & Len(TextBox2)
End Sub