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
| Option Explicit
Private Sub Form_Load()
With Combo1
.AddItem "Computer": .AddItem "Screen"
.AddItem "Modem": .AddItem "Moderne"
.AddItem "Modus": .AddItem "Printer"
.AddItem "Scanner": .AddItem "Sound Blaster"
.AddItem "Keyboard": .AddItem "CD-Rom"
.AddItem "Mouse": .AddItem "Sourdingue"
End With
End Sub
Private Sub Text1_Change()
Combo1.ListIndex = Idx(Text1.Text)
End Sub
Public Function Idx(Quoi As String) As Integer
Idx = -1: Quoi = UCase(Quoi)
Dim T As Integer
For T = 0 To Combo1.ListCount - 1
If InStr(UCase(Combo1.List(T)), Quoi) <> 0 Then
If InStr(UCase(Combo1.List(T)), Quoi) = 1 Then 'trie que si les n premiers caratères saisie
Idx = T
Exit Function
End If
End If
Next T
End Function |
Partager