Bonjour Huert, bonjour le forum,
Pour les dates, peut-être comme ça :
Private Sub TextBox2_Exit(ByVal Cancel As MSForms.ReturnBoolean)
If IsDate(Me.TextBox2.Value) = False Then
Cancel = True
MsgBox "Date non valide ! Vous devez utiliser le format jj/mm/aaa !"
With TextBox2
.SelStart = 0
.SelLength = Len(.Value)
End With
GoTo fin
End If
If UBound(Split(Me.TextBox2.Value, "/")) <> 2 Or Len(Me.TextBox2.Value) <> 10 Then
Cancel = True
MsgBox "Date non valide ! Vous devez utiliser le format jj/mm/aaa !"
With TextBox2
.SelStart = 0
.SelLength = Len(.Value)
End With
End If
fin:
End Sub
pour les chiffres :
Sheets("DEMANDES").Range("ZZZ" & Maligne)=CDBL(TextBox___.Value)
Mais ça plante si tu rentres le point comme séparateur décimal... Il faut utilser pour chaque textboxes qui contient des données numériques non entières un code du type :
Private Sub TextBox2_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
If KeyAscii = 44 Then Exit Sub 'permet l'appuie sur la touche "," (virgule)
If KeyAscii = 46 Then KeyAscii = 44: Exit Sub 'remplace le point "." par une virgule ","
If KeyAscii < 48 Or KeyAscii > 57 Then KeyAscii = 8 'efface tout autre caractère que {0, 1, 2, 3, 4, 5, 6, 7, 8 et 9}
End Sub