1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| Private Sub ComboBox1_KeyUp(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
Static mem As Long
With ComboBox1
If KeyCode = 8 Then mem = mem - IIf(mem > 0, 1, 0): .Value = Left(.Value, mem) Else mem = mem + 1 'gestion de la touche back
If KeyCode <> 8 And KeyCode <> 46 And .ListIndex = -1 Then
mem = mem - IIf(mem > 0, 1, 0)
.Value = Left(.Value, mem) 'gestion de la validité de la chaine tapée
End If
If KeyCode = 46 Then mem = 0: .Value = ""
TextBox1 = Left(.Value, mem)
.DropDown
End With
End Sub
'
'
Private Sub UserForm_Activate()
Me.ComboBox1.List = Array("pomme", "banane", "ananas", "poire", "raisin", "tomate", "jambon", "cerise")
End Sub |
Partager