Userform

Delage

XLDnaute Nouveau
Bonsoir,
j'ai construit une boite de dialogue avec excel. presque bien sauf que our le code postal, j'aimerai pouvoir être obligé de renter u'une valeur du numérique, avec une longueur de chaine de 5 caractères. Voici la formule que j'ai mis en place; Malheureusement je arrive pas à trouvé la bonne formule:

Private Sub CommandButton3_Click()
If UF_Code.Value = "" Then 'SI pas de "nom" ...
Label2.ForeColor = RGB(255, 0, 0) 'Labelé "code" en rouge
MsgBox "Vous devez ABSOLUMENT indiquer le code attribué à l'entreprise !", vbExclamation, _
"ERREUR ... Code de l'entreprise SVP !"
ElseIf UF_Etablissement.Value = "" Then
Label3.ForeColor = RGB(255, 0, 0)
MsgBox "Vous devez ABSOLUMENT indiquer le nom de l'entreprise !", vbExclamation, _
"ERREUR ... Nom de l'entreprise SVP !"
ElseIf UF_Adresse.Value = "" Then
Label4.ForeColor = RGB(255, 0, 0)
MsgBox "Vous devez ABSOLUMENT indiquer l'adresse de l'entreprise !", vbExclamation, _
"ERREUR ... Adresse de l'entreprise SVP !"
ElseIf UF_CP.Value = "" Then
Label5.ForeColor = RGB(255, 0, 0)
MsgBox "Vous devez ABSOLUMENT indiquer le code postal de l'entreprise !", vbExclamation, _
"ERREUR ... Code postal de l'entreprise SVP !"
ElseIf IsNumeric(UF_CP.Value) Then 'SI valeur numérique ...
Label_erreur.Visible = False
ElseIf IsNumeric(UF_CP.Value) Then 'SI valeur numérique ...
Label_erreur.Visible = true
MsgBox "Valeur du code postal incorrecte"

ElseIf UF_Ville.Value = "" Then
Label6.ForeColor = RGB(255, 0, 0)
MsgBox "Vous devez ABSOLUMENT indiquer la ville où se implantée l'entreprise !", vbExclamation, _
"ERREUR ... La ville SVP !"
ElseIf UF_Télèphone.Value = "" Then
Label7.ForeColor = RGB(255, 0, 0)
MsgBox "Vous devez ABSOLUMENT indiquer les coordonnées télèphoniques de l'entreprise !", vbExclamation, _
"ERREUR ... coordonnées télèphoniques SVP !"
ElseIf UF_portable.Value = "" Then
Label9.ForeColor = RGB(255, 0, 0)
MsgBox "Vous devez ABSOLUMENT indiquer les coordonnées télèphoniques de l'entreprise !", vbExclamation, _
"ERREUR ... coordonnées télèphoniques SVP !"
ElseIf UF_attention.Value = "" Then
Label10.ForeColor = RGB(255, 0, 0)
MsgBox "Vous devez ABSOLUMENT indiquer à qui il faut envoyé la convention !", vbExclamation, _
"ERREUR .A l'attention de.. SVP !"
ElseIf UF_representé.Value = "" Then
Label11.ForeColor = RGB(255, 0, 0)
MsgBox "Vous devez ABSOLUMENT indiquer le nom du représentant légal de l'entreprise !", vbExclamation, _
"ERREUR ... représentant légal SVP !"
ElseIf UF_Fonction.Value = "" Then
Label12.ForeColor = RGB(255, 0, 0)
MsgBox "Vous devez ABSOLUMENT indiquer la fonction du représentant légal !", vbExclamation, _
"ERREUR ... fonction du représentant légal SVP !"
ElseIf UF_contact.Value = "" Then
Label13.ForeColor = RGB(255, 0, 0)
MsgBox "Vous devez ABSOLUMENT indiquer le nom de votre contact de l'entreprise !", vbExclamation, _
"ERREUR ... 'Contact de l'entreprise' SVP !"
ElseIf UF_activité.Value = "" Then
Label14.ForeColor = RGB(255, 0, 0)
MsgBox "Vous devez ABSOLUMENT indiquer l'activité principale l'entreprise !", vbExclamation, _
"ERREUR ... 'l'activité principale' SVP !"
ElseIf UF_adresse2.Value = "" Then
Label15.ForeColor = RGB(255, 0, 0)
MsgBox "Vous devez ABSOLUMENT indiquer l'adresse du lieu du stage !", vbExclamation, _
"ERREUR ... adresse du lieu du stage SVP !"
ElseIf UF_CP2.Value = "" Then
Label16.ForeColor = RGB(255, 0, 0)
MsgBox "Vous devez ABSOLUMENT indiquer le code postal du lieu stage !", vbExclamation, _
"ERREUR ... 'code postal du lieu stage' SVP !"
ElseIf UF_Ville2.Value = "" Then
Label17.ForeColor = RGB(255, 0, 0)
MsgBox "Vous devez ABSOLUMENT indiquer la ville du lieu stage !", vbExclamation, _
"ERREUR ... la ville du lieu stage SVP !"
ElseIf UF_Maitre2.Value = "" Then
Label18.ForeColor = RGB(255, 0, 0)
MsgBox "Vous devez ABSOLUMENT indiquer le nom du maitre de stage !", vbExclamation, _
"ERREUR ... nom du maitre de stage SVP !"
ElseIf UF_TEL2.Value = "" Then
Label19.ForeColor = RGB(255, 0, 0)
MsgBox "Vous devez ABSOLUMENT indiquer le numéro de télèphone du lieu de stage !", vbExclamation, _
"ERREUR ... Code postal de l'entreprise SVP !"
ElseIf UF_MALU.Value = "" Then
Label20.ForeColor = RGB(255, 0, 0)
MsgBox "Vous devez ABSOLUMENT indiquer les horaires du lundi matin !", vbExclamation, _
"ERREUR ... horaires du lundi matin SVP !"
ElseIf UF_APLU.Value = "" Then
Label20.ForeColor = RGB(255, 0, 0)
MsgBox "Vous devez ABSOLUMENT indiquer les horaires du lundi après midi !", vbExclamation, _
"ERREUR ... horaires du lundi après midi SVP !"
ElseIf UF_MAMA.Value = "" Then
Label21.ForeColor = RGB(255, 0, 0)
MsgBox "Vous devez ABSOLUMENT indiquer les horaires du mardi matin !", vbExclamation, _
"ERREUR ... les horaires du mardi matin SVP !"
ElseIf UF_APMA.Value = "" Then
Label21.ForeColor = RGB(255, 0, 0)
MsgBox "Vous devez ABSOLUMENT indiquer les horaires du mardi après midi !", vbExclamation, _
"ERREUR ... mardi après midi SVP !"
ElseIf UF_MAME.Value = "" Then
Label22.ForeColor = RGB(255, 0, 0)
MsgBox "Vous devez ABSOLUMENT indiquer les horaires du mercredi matin !", vbExclamation, _
"ERREUR ... les horaires du mercredi matin SVP !"
ElseIf UF_APME.Value = "" Then
Label22.ForeColor = RGB(255, 0, 0)
MsgBox "Vous devez ABSOLUMENT indiquer les horaires du mercredi après midi !", vbExclamation, _
"ERREUR ... les horaires du mercredi après midi SVP !"
ElseIf UF_MAJE.Value = "" Then
Label23.ForeColor = RGB(255, 0, 0)
MsgBox "Vous devez ABSOLUMENT indiquer les horaires du jeudi matin !", vbExclamation, _
"ERREUR ... les horaires du mercredi matin SVP !"
ElseIf UF_APJE.Value = "" Then
Label23.ForeColor = RGB(255, 0, 0)
MsgBox "Vous devez ABSOLUMENT indiquer les horaires du jeudi après midi !", vbExclamation, _
"ERREUR ... les horaires du jeudi après midi SVP !"
ElseIf UF_MAVE.Value = "" Then
Label24.ForeColor = RGB(255, 0, 0)
MsgBox "Vous devez ABSOLUMENT indiquer les horaires du vendredi matin !", vbExclamation, _
"ERREUR ... les horaires du vendredi matin SVP !"
ElseIf UF_APVE.Value = "" Then
Label24.ForeColor = RGB(255, 0, 0)
MsgBox "Vous devez ABSOLUMENT indiquer les horaires du vendredi après midi !", vbExclamation, _
"ERREUR ...les horaires du vendredi après midi SVP !"
ElseIf UF_MASA.Value = "" Then
Label25.ForeColor = RGB(255, 0, 0)
MsgBox "Vous devez ABSOLUMENT indiquer les horaires du samedi matin !", vbExclamation, _
"ERREUR ... les horaires du samedi matin SVP !"
ElseIf UF_APSA.Value = "" Then
Label25.ForeColor = RGB(255, 0, 0)
MsgBox "Vous devez ABSOLUMENT indiquer les horaires du samedi après midi !", vbExclamation, _
"ERREUR ... les horaires du samedi après midi SVP !"
End If

'End With
'Sélection de la ligne du formulaire en cas de changement
'Rows(ligne).Select
End Sub

UF_CP correspond au code postal.

merci de votre aide
m.d
 

kjin

XLDnaute Barbatruc
Re : Userform

Bonsoir,
Inutile de poster tout le code...
Code:
Private Sub UF_CP_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
If InStr(1, 1234567890, Chr(KeyAscii)) = 0 Then KeyAscii = 0
If Len(UF_CP) = 5 Then KeyAscii = 0
End Sub
A+
kjin
 

Statistiques des forums

Discussions
312 298
Messages
2 086 978
Membres
103 417
dernier inscrit
abaabdelghani