Sub IsValidFormatDate(DateIn As String) As Boolean
''' Log(IsValidDate("13-31-1212")) 'false
''' Log(IsValidDate("12-31-1212")) 'true
''' Date Format ---> "dd-MM-yyyy"
Dim matcher1 As Matcher
matcher1 = Regex.Matcher("(\d\d)-(\d\d)-(\d\d\d\d)", DateIn)
If matcher1.Find = True Then
Dim days, months As Int
days = matcher1.Group(1) 'fetch the second captured group
months = matcher1.Group(2) 'fetch the first captured group.
If months > 12 Then Return False
If days > 31 Then Return False
' Return True
Else
Return False
End If
' se il formato è valido controlla i valori inseriti nel dd e MM ( 31-06 oppure 30-02 )
DateTime.DateFormat = "dd-MM-yyyy" 'or what ever format is required
Try
DateTime.DateParse(DateIn)
Return True
' Log("Ok date")
Catch
Return False
' Log("error date")
End Try
End Sub