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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
| Option Explicit
'API qui permet de faire la recherche des lettres entrée dans Text2
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Integer, ByVal lParam As Any) As Long
Dim X As Integer
Private Sub Form_Load()
'placement des objets
Text2.Left = 2250: Text2.Top = 30: Text2.Width = 2070:Text2 = ""
List7.Left = 60: List7.Top = 360: List7.Width = 2055: List7.Height = 2400
List8.Left = 2250: List7.Top = 360: List7.Width = 2055: List7.Height = 2400
Command1.Left = 1350: Command1.Top = 2820: Command1.Width = 1695
Command1.Height = 315: Command1.Caption = ">--- rechercher --->"
Label1.Left = 90: Label1.Top = 3210: Label1.Width = 4290
Label1.Height = 195: Label1 = ""
Me.Height = 3870: Me.Width = 4515
'Initialisation des listes
List7.Clear: List8.Clear
For X = 0 To 10
List7.AddItem "Choix " & CStr(X)
List8.AddItem "Choix " & CStr(X + 11)
Next X
List7.List(1) = "A retrouver"
List8.List(10) = "A retrouver"
End Sub
Private Sub Command1_Click()
'retrouver une ligne identique de list7 dans List8
Dim I As Integer
Dim MotTrouver As Boolean
MotTrouver = False
For I = 0 To List7.ListCount - 1
For X = 0 To List8.ListCount - 1
If List8.List(X) = List7.List(I) Then
MotTrouver = True
Exit For ' sortie de la boucle For X
End If
Next X
If MotTrouver = True Then
' sortie de la boucle For I
Exit For
End If
Next I
If MotTrouver = False Then
Label1 = "Aucune ligne identique dans List7 n'a ètè trouvé dans List8"
Else
Label1 = "la ligne N°" & CStr(I + 1) _
& " de list7 est identique à la ligne N°" _
& CStr(X + 1) & " de List8"
'selection des deux lignes identiques
List7.Selected(I) = True: List8.Selected(X) = True
End If
End Sub
Private Sub Text2_Change()
'ici le contenu de Text2 est recherché dans List8
List8.ListIndex = SendMessage(List8.hwnd, &H18F, -1, ByVal CStr(Text2.Text))
End Sub |