Option Explicit
Public WithEvents tb As MSForms.TextBox
Private Sub tb_Change()
Dim t
If tb = "" Then Exit Sub
If Len(tb) = 2 Or Len(tb) = 5 Then tb = tb & "/"
If Len(tb) = 10 Then
If Not IsDate(tb) Then GoTo fin
t = Split(tb, "/")
If CInt(t(1)) > 12 Or CInt(t(0)) > Day(DateSerial(CInt(t(2)), CInt(t(1)) + 1, 0)) Then GoTo fin
End If
Exit Sub
fin:
MsgBox "saisie erronée": tb = ""
End Sub
Private Sub tb_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
If InStr("0123456789", Chr(KeyAscii)) = 0 Then KeyAscii = 0
End Sub