Bonjour,
voici 2 exemples, et il en existe bien d'autres.
Private Sub TextBox1_Change()
If (Len(TextBox1.Value) > 3) Then
MsgBox "Ne doit pas excéder 999"
Else
If (Val(TextBox1.Value) > -1) And (Val(TextBox1.Value) < 1000) Then
MsgBox "Valeur acceptée"
Else
MsgBox "Le nombre doit être comprit entre 0 et 999"
End If
End If
End Sub
'
Private Sub TextBox2_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
If (KeyAscii <> "13") Then
If (Len(TextBox1.Value) > 3) Then
MsgBox "Le nombre de caractère est invalide"
Else
If ((KeyAscii >= 0) And (KeyAscii <= 9)) Then
If (Val(TextBox1.Value) > -1) And (Val(TextBox1.Value) < 1000) Then
MsgBox "Valeur acceptée"
Else
MsgBox "Le nombre doit être comprit entre 0 et 999"
End If
End If
End If
End If
End Sub
Lupin