Effacer textbox

Résolu/Fermé
JSCH19 Messages postés 129 Date d'inscription mercredi 30 octobre 2019 Statut Membre Dernière intervention 22 juin 2023 - 25 juin 2021 à 07:54
JSCH19 Messages postés 129 Date d'inscription mercredi 30 octobre 2019 Statut Membre Dernière intervention 22 juin 2023 - 25 juin 2021 à 20:05
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 22701 Date d'inscription lundi 9 juin 2008 Statut Contributeur Dernière intervention 19 avril 2024 1 471
25 juin 2021 à 09:01
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 129 Date d'inscription mercredi 30 octobre 2019 Statut Membre Dernière intervention 22 juin 2023
25 juin 2021 à 18:44
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 129 Date d'inscription mercredi 30 octobre 2019 Statut Membre Dernière intervention 22 juin 2023
Modifié le 25 juin 2021 à 19:48
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 22701 Date d'inscription lundi 9 juin 2008 Statut Contributeur Dernière intervention 19 avril 2024 1 471
25 juin 2021 à 19:11
qu'as-tu essayé?
0
JSCH19 Messages postés 129 Date d'inscription mercredi 30 octobre 2019 Statut Membre Dernière intervention 22 juin 2023
Modifié le 25 juin 2021 à 19:48
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 22701 Date d'inscription lundi 9 juin 2008 Statut Contributeur Dernière intervention 19 avril 2024 1 471 > JSCH19 Messages postés 129 Date d'inscription mercredi 30 octobre 2019 Statut Membre Dernière intervention 22 juin 2023
25 juin 2021 à 19:54
et cela a donné quoi?
0
JSCH19 Messages postés 129 Date d'inscription mercredi 30 octobre 2019 Statut Membre Dernière intervention 22 juin 2023 > yg_be Messages postés 22701 Date d'inscription lundi 9 juin 2008 Statut Contributeur Dernière intervention 19 avril 2024
25 juin 2021 à 20:05
Ca fonctionne tres bien maintenant. je l'ai fait en te parlant.
0