Excel vba valider si textbox non vides
Résolu
lulu37
Messages postés
80
Statut
Membre
-
lulu37 Messages postés 80 Statut Membre -
lulu37 Messages postés 80 Statut Membre -
Bonjour,
Comment effectuer un controle de saisie sur un formulaire à 3 textbox?
Je voudrais à la validation du formulaire, que les 3 textbox ne soient pas vides.
Si elles sont vides, que ca retourne au meme formulaire, et si non vides, que ca continue la macro de validation.
mon code actuel est le suivant :
Private Sub OK_Click()
'controle saisie des 3 criteres d identification'
If ListBoxService = "" Then
MsgBox "Vous devez renseigner les 3 critères d'identification.", 0, "Information"
End If
If TextBoxNom = "" Then
MsgBox "Vous devez renseigner les 3 critères d'identification.", 0, "Information"
End If
If TextBoxPrenom = "" Then
MsgBox "Vous devez renseigner les 3 critères d'identification.", 0, "Information"
End If
...suite macro...
UserForm1.Hide
UserForm2.Show
End Sub
du coup ca me met bien les msgbox, mais la macro continue...alors que je voudrais qu'elle s'arrete si la valeur est nulle.
J'ai essayé d'inscrire End Sub dans le corps If mais ce ne fonctionne pas non plus ...
Pouvez vous m'aider?
Merci d'avance
Comment effectuer un controle de saisie sur un formulaire à 3 textbox?
Je voudrais à la validation du formulaire, que les 3 textbox ne soient pas vides.
Si elles sont vides, que ca retourne au meme formulaire, et si non vides, que ca continue la macro de validation.
mon code actuel est le suivant :
Private Sub OK_Click()
'controle saisie des 3 criteres d identification'
If ListBoxService = "" Then
MsgBox "Vous devez renseigner les 3 critères d'identification.", 0, "Information"
End If
If TextBoxNom = "" Then
MsgBox "Vous devez renseigner les 3 critères d'identification.", 0, "Information"
End If
If TextBoxPrenom = "" Then
MsgBox "Vous devez renseigner les 3 critères d'identification.", 0, "Information"
End If
...suite macro...
UserForm1.Hide
UserForm2.Show
End Sub
du coup ca me met bien les msgbox, mais la macro continue...alors que je voudrais qu'elle s'arrete si la valeur est nulle.
J'ai essayé d'inscrire End Sub dans le corps If mais ce ne fonctionne pas non plus ...
Pouvez vous m'aider?
Merci d'avance
A voir également:
- Excel vba valider si textbox non vides
- Si ou excel - Guide
- Liste déroulante excel - Guide
- Word et excel gratuit - Guide
- Excel cellule couleur si condition texte - Guide
- Déplacer colonne excel - Guide
4 réponses
Salut!
-Modifier ton code comme ça , ajoute "Dim rien" et remplace:
Private Sub OK_Click()
Dim rien
'controle saisie des 3 criteres d identification'
If ListBoxService = rien Then
MsgBox "Vous devez renseigner les 3 critères d'identification.", 0, "Information"
End If
If TextBoxNom = rien Then
MsgBox "Vous devez renseigner les 3 critères d'identification.", 0, "Information"
End If
If TextBoxPrenom = rien Then
MsgBox "Vous devez renseigner les 3 critères d'identification.", 0, "Information"
End If
A+
-Modifier ton code comme ça , ajoute "Dim rien" et remplace:
Private Sub OK_Click()
Dim rien
'controle saisie des 3 criteres d identification'
If ListBoxService = rien Then
MsgBox "Vous devez renseigner les 3 critères d'identification.", 0, "Information"
End If
If TextBoxNom = rien Then
MsgBox "Vous devez renseigner les 3 critères d'identification.", 0, "Information"
End If
If TextBoxPrenom = rien Then
MsgBox "Vous devez renseigner les 3 critères d'identification.", 0, "Information"
End If
A+
Salut!
moi je utilise vb6 et non vb for office peut-étre ça:
-Essai ça:
Private Sub OK_Click()
Dim rien
'controle saisie des 3 criteres d identification'
If ListBoxService = rien Then
MsgBox "Vous devez renseigner les 3 critères d'identification.", 0, "Information"
Exit sub
End If
If TextBoxNom = rien Then
MsgBox "Vous devez renseigner les 3 critères d'identification.", 0, "Information"
Exit sub
End If
If TextBoxPrenom = rien Then
MsgBox "Vous devez renseigner les 3 critères d'identification.", 0, "Information"
Exit sub
End If
moi je utilise vb6 et non vb for office peut-étre ça:
-Essai ça:
Private Sub OK_Click()
Dim rien
'controle saisie des 3 criteres d identification'
If ListBoxService = rien Then
MsgBox "Vous devez renseigner les 3 critères d'identification.", 0, "Information"
Exit sub
End If
If TextBoxNom = rien Then
MsgBox "Vous devez renseigner les 3 critères d'identification.", 0, "Information"
Exit sub
End If
If TextBoxPrenom = rien Then
MsgBox "Vous devez renseigner les 3 critères d'identification.", 0, "Information"
Exit sub
End If