Bonjour,
Je cherchais à faire de la saisie semi automatique dans une combobox et je suis tombé sur ça :
bien joli tout ça cependant il y'a une partie que je ne comprend pas :
For i = cBox.ListCount To 0 Step -1 And Done = False
Que veux dire exactement ce "And Done" ?
Pour i est égal cbox.listCount jusqu'à 0 en ajoutant à chaque fois -1 -> Pas de soucis mais And Done je vois pas : /
Je cherchais à faire de la saisie semi automatique dans une combobox et je suis tombé sur ça :
Code:
' M O D U L E
'--------------------------------------------------------------------------------
' www.idev.fr.st
'
' Syntax
' ------
' In the CHANGE event of your ComboBox, put in the following line
' iSenseChange YourComboBoxName
' Where "YourComboBoxName" is the name of the ComboBox associated with the event.
'
' In the KEYPRESS event of your ComboBox, put in the following line
' iSenseKeyPress YourComboBoxName, KeyAscii
' Where "YourComboBoxName" is the name of the ComboBox associated with the event.'
'
' ADAPTED FROM :
'--------------------------------------------------------------------------------
' IntelliSense for VB the TextBox Control.
' Danny Young
' dan@mydan.com
' http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=9313&lngWId=1
'--------------------------------------------------------------------------------
Option Explicit
Global WasDelete As Boolean
Public Function IntelliSense(cBox As ComboBox, AddRecord As Boolean) As String
Dim i As Integer
Dim Done As Boolean
If AddRecord Then
'Pour ajouter le texte dans la ComboBox
'cBox.AddItem cBox.Text
Else
' For i = 0 To cBox.ListCount And Done = False
For i = cBox.ListCount To 0 Step -1 And Done = False
If UCase(cBox.Text) = Mid(RTrim(UCase(cBox.List(i))), 1, Len(cBox.Text)) Then
IntelliSense = RTrim(cBox.List(i))
End If
Next i
End If
End Function
Public Sub iSenseChange(cBox As ComboBox)
Dim iStart As Integer
Dim iSense As String
iStart = cBox.SelStart
iSense = IntelliSense(cBox, False)
If iSense <> "" And Not WasDelete Then
cBox.Text = iSense
cBox.SelStart = iStart
cBox.SelLength = Len(cBox.Text) - iStart
End If
End Sub
Public Sub iSenseKeyPress(cBox As ComboBox, KeyAscii As Integer)
If KeyAscii = 13 And cBox.Text <> "" Then
IntelliSense cBox, True
ElseIf KeyAscii = 8 Then
WasDelete = True
Else
WasDelete = False
End If
End Sub
bien joli tout ça cependant il y'a une partie que je ne comprend pas :
For i = cBox.ListCount To 0 Step -1 And Done = False
Que veux dire exactement ce "And Done" ?
Pour i est égal cbox.listCount jusqu'à 0 en ajoutant à chaque fois -1 -> Pas de soucis mais And Done je vois pas : /