Effacer textbox

Résolu
JSCH19 Messages postés 128 Date d'inscription   Statut Membre Dernière intervention   -  
JSCH19 Messages postés 128 Date d'inscription   Statut Membre Dernière intervention   -
Bonjour les amis,
Dans un userform je dispose de 4 textboxes alignees cote a cote,chaque textbox a un maxlength de 5,j'ai mis un bout de code afin d'interdire d'effacer une textbox si la textbox d'apres n'est pas vide qui marche a merveille.
je cherche une maniere efficace a effacer les textboxes en commencant par la toute derniere textbox et si celle-ci est vide de passer au precedent automatiquement ainsi de suite.

Voici un lien pour pouvoir illustrer ce que je demande:
https://accounts.google.com/ServiceLogin?service=wise&passive=1209600&continue=https://drive.google.com/file/d/1aq0i-F7QqBLBNARLbcuiWoVut_SQ4hJm/view?usp%3Dsharing&followup=https://drive.google.com/file/d/1aq0i-F7QqBLBNARLbcuiWoVut_SQ4hJm/view?usp%3Dsharing
Merci deja pour vos interventions.

2 réponses

yg_be Messages postés 23541 Date d'inscription   Statut Contributeur Dernière intervention   Ambassadeur 1 583
 
bonjour,
ton lien n'est pas accessible par tous.
à quel moment faut-il effacer les textboxes?
quelle difficulté rencontres-tu, qu'as-tu essayé?
0
JSCH19 Messages postés 128 Date d'inscription   Statut Membre Dernière intervention  
 
Bonjour yg_be je ne sais pas comment l'expliquer ,cela aurait ete plus comprehensible avec le fichier excel. Je vais essayer d'expliquer, vous savez voir quand vous rentrez la clé d'activation d'un produit etc... puis quand vous rentrez le code dans les textboxes et si la textboxe d'apres n'est pas vide vous ne pouvez pas corriger un contenu dans celle precedente, alors c'est ce que j'aimerais pouvoir faire.En gros comme je dispose de 4 textboxes aligne cote a cote,je veux commencer par effacer le contenu des textboxes en commencant par la quatrieme et une fois celle-ci vide passer automatiquement a la 3eme et ainsi de suite
0
JSCH19 Messages postés 128 Date d'inscription   Statut Membre Dernière intervention  
 
Option Explicit
Private Sub TextBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If Me.TextBox2 <> Empty Then
KeyCode = 0
End If
End Sub

Private Sub TextBox1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
If Len(Me.TextBox1) = Me.TextBox1.MaxLength - 1 Then
Me.TextBox1 = Me.TextBox1 + Chr(KeyAscii)
Me.TextBox2 = Empty
Me.TextBox2.SetFocus
End If
End Sub

Private Sub TextBox2_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If Me.TextBox3 <> Empty Then
KeyCode = 0
End If
End Sub

Private Sub TextBox2_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
If Len(Me.TextBox2) = Me.TextBox2.MaxLength - 1 Then
Me.TextBox2 = Me.TextBox2 + Chr(KeyAscii)
Me.TextBox3 = Empty
Me.TextBox3.SetFocus
End If

End Sub

Private Sub TextBox3_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If Me.TextBox4 <> Empty Then
KeyCode = 0
End If
End Sub

Private Sub TextBox3_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
If Len(Me.TextBox3) = Me.TextBox3.MaxLength - 1 Then
Me.TextBox3 = Me.TextBox3 + Chr(KeyAscii)
Me.TextBox4 = Empty
Me.TextBox4.SetFocus
End If
End Sub



Tout marche a merveille,des que je me positionne sur la premiere textboxe je ne fais que rentrer les donnees cela passe automatiquement a la deuxieme une fois le maxlength est true ainsi de suite.
je veux faire de meme quand j'efface le contenu des textboxes.
0
yg_be Messages postés 23541 Date d'inscription   Statut Contributeur Dernière intervention   1 583
 
qu'as-tu essayé?
0
JSCH19 Messages postés 128 Date d'inscription   Statut Membre Dernière intervention  
 
Option Explicit
Private Sub TextBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If Me.TextBox2 <> Empty Then
KeyCode = 0
End If
End Sub

Private Sub TextBox1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
If Len(Me.TextBox1) = Me.TextBox1.MaxLength - 1 Then
Me.TextBox1 = Me.TextBox1 + Chr(KeyAscii)
Me.TextBox2 = Empty
Me.TextBox2.SetFocus
End If
End Sub

Private Sub TextBox2_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If Me.TextBox3 <> Empty Then
KeyCode = 0
End If

If Me.TextBox2 = Empty Then
Me.TextBox1.SetFocus
KeyCode = 46
End If
End Sub

Private Sub TextBox2_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
If Len(Me.TextBox2) = Me.TextBox2.MaxLength - 1 Then
Me.TextBox2 = Me.TextBox2 + Chr(KeyAscii)
Me.TextBox3 = Empty
Me.TextBox3.SetFocus
End If

End Sub

Private Sub TextBox3_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If Me.TextBox4 <> Empty Then
KeyCode = 0
End If

If Me.TextBox3 = Empty Then
Me.TextBox2.SetFocus
KeyCode = 46
End If
End Sub

Private Sub TextBox3_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
If Len(Me.TextBox3) = Me.TextBox3.MaxLength - 1 Then
Me.TextBox3 = Me.TextBox3 + Chr(KeyAscii)
Me.TextBox4 = Empty
Me.TextBox4.SetFocus
End If
End Sub

Private Sub TextBox4_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If Me.TextBox4 = Empty Then
Me.TextBox3.SetFocus
KeyCode = 46
End If
End Sub

Voila ce que j'ai essaye
0
yg_be Messages postés 23541 Date d'inscription   Statut Contributeur Dernière intervention   1 583 > JSCH19 Messages postés 128 Date d'inscription   Statut Membre Dernière intervention  
 
et cela a donné quoi?
0
JSCH19 Messages postés 128 Date d'inscription   Statut Membre Dernière intervention   > yg_be Messages postés 23541 Date d'inscription   Statut Contributeur Dernière intervention  
 
Ca fonctionne tres bien maintenant. je l'ai fait en te parlant.
0