Groupe de controles différents dans un tableau
Bonjours,
J ai un problème j'ai une forme avec 4 controles Text(0),Text(1),Text(2) etText_ha.
Je voudrais effectuer les mêmes vérifications de saisie pour l’ensemble
des zones de texte sur la form.
Voici mon code :
Code:
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
|
Option Base 1
Dim t(1 To 4) As Control
Dim int_index As Integer
Private Sub Form_Load()
Me.Show
Set t(1) = Text(0)
Set t(2) = Text(1)
Set t(3) = Text_ha
'Set t(3) = List
Set t(4) = Text(2)
End Sub
Private Sub Text_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Or KeyCode = vbKeyDown Then
int_index = int_index + 1
If int_index > 4 Then int_index = 1
t(int_index).SetFocus
ElseIf KeyCode = vbKeyUp Then
int_index = int_index - 1
If int_index < 1 Then int_index = 4
t(int_index).SetFocus
ElseIf KeyCode = vbKeyPageUp Then
int_index = 1
t(int_index).SetFocus
ElseIf KeyCode = vbKeyPageDown Then
int_index = 4
t(int_index).SetFocus
End If
End Sub |
Le problème c est que ça ne marche pas du tout :oops::oops: .
SI quelle qu'un a une solution a me proposer
Merci d'avance .