1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
Sub test_date()
Dim val
Dim tabl
Dim car
Dim i As Integer
val = InputBox("date à saisir", "controle format date")
If Len(val) <> 19 Then MsgBox "le format est incorrecte": Exit Sub
i = 1
tabl = Array(1, 2, 4, 5, 7, 8, 9, 10, 12, 13, 15, 16, 18, 19)
Do While i < UBound(tabl)
car = Mid(val, tabl(i), 1)
If Not IsNumeric(car) Then
MsgBox "le format est incorrecte"
Exit Sub
End If
i = i + 1
Loop
If Mid(val, 3, 1) <> "/" Or Mid(val, 6, 1) <> "/" _
Or Mid(val, 11, 1) <> " " Or Mid(val, 14, 1) <> ":" _
Or Mid(val, 17, 1) <> ":" Then
MsgBox "le format est incorrecte"
Exit Sub
Else: MsgBox "saisie correcte"
End If
End Sub |
Partager