Private Sub TextBox1_Change() 'filtre listbox via textbox
If flag Then Exit Sub
'If liste(1, 1) = "" Then Exit Sub
Dim critere$, i&, a$(), n&
critere = "*" & LCase(Trim(TextBox1)) & "*"
For i = 1 To UBound(liste, 2)
If LCase(liste(2, i)) Like critere Then
n = n + 1
ReDim Preserve a(1 To 2, 1 To n)
a(1, n) = liste(1, i)
a(2, n) = liste(2, i)
End If
Next
ListBox2.Clear 'RAZ
ListBox1.Clear 'RAZ
If n Then If n > 1 Then ListBox1.List = Application.Transpose(a) Else ListBox1.AddItem a(1, 1): ListBox1.List(0, 1) = a(2, 1)
End Sub
Private Sub ListBox1_Click()
Dim myFile, IdFile As Integer, TextLine As String
myFile = ListBox1.List(ListBox1.ListIndex, 1)
flag = True 'bloque TextBox1_Change
TextBox1 = ListBox1
flag = False
ListBox2.Clear 'RAZ
IdFile = FreeFile
Open myFile For Input As #IdFile
Do While Not EOF(IdFile)
Line Input #IdFile, TextLine
ListBox2.AddItem TextLine
Loop
Close #IdFile
End Sub