mythiac
Messages postés72Date d'inscriptionmardi 23 septembre 2008StatutMembreDernière intervention23 février 2009
-
24 déc. 2008 à 15:03
mythiac
Messages postés72Date d'inscriptionmardi 23 septembre 2008StatutMembreDernière intervention23 février 2009
-
24 déc. 2008 à 16:12
bonjour,
j'aimerais savoir comment interrompre un commandbutton
en gros, obliger à remplir tous les champs mais comme ceci:
Private Sub CommandButton2_Click()
If UserForm14.TextBox1 "" Or UserForm14.ComboBox1 "" Or UserForm14.TextBox2 = "" Or UserForm14.TextBox3 = "" Or UserForm14.TextBox4 = "" Or UserForm14.TextBox5 = "" Or UserForm14.TextBox6 = "" Then
MsgBox "Remplir tous les champs"
' revenir sur le textbox1
End If
..............suite des instructions
End Sub
pour info, je ne vaux pas faire comme ça:
Private Sub TextBox15_Change()
Dim valeur As Byte
TextBox15.MaxLength = 10 'nbr caractère max
valeur = Len(TextBox15) If valeur 2 Or valeur 5 Then TextBox15 = TextBox15 & "/"
TextBox15.AutoTab = True 'autotabulation
PCPT
Messages postés13272Date d'inscriptionlundi 13 décembre 2004StatutMembreDernière intervention 3 février 201847 24 déc. 2008 à 16:07
salut,
IF condition
action 1
SINON
action 2
FIN
il ne faut pas forcément "quitter" (ce qui se ferait avec exit sub), le ELSE sert à ton test de condition
Private Sub
CommandButton2_Click()
If UserForm14.TextBox1.Text = "" Or _
UserForm14.ComboBox1.Text = "" Or _
UserForm14.TextBox2.Text = "" Or _
UserForm14.TextBox3.Text = "" Or _
UserForm14.TextBox4.Text = "" Or _
UserForm14.TextBox5.Text = "" Or _
UserForm14.TextBox6.Text = "" Then
MsgBox "Remplir tous les
champs"
UserForm14.TextBox1.SetFocus ' <-
pour revenir sur le textbox1
Else
'..............suite
des instructions
End If
End Sub