|
-
Jul 27th, 2000, 09:55 AM
#4
IsDate checks if the passed date is valid in any format. for example if you accept the date in m/d/yy format a test with isdate for 13/2/00 would be valid because it is a valid date in the d/m/yy format.
I use the following function in all my applications.
Private Function ValidDate(strDate As String) As Boolean
Dim intMonth As Integer
Dim intDay As Integer
Dim intYear As Integer
If Len(Trim$(strDate)) < 8 Then
ValidDate = True
Exit Function
End If
intMonth = Int(Left(strDate, 2))
intDay = Int(Mid(strDate, 3, 2))
intYear = Int(Right(strDate, 4))
ValidDate = True
If intMonth > 12 Or intDay > 31 Then
ValidDate = False
Exit Function
End If
If (intMonth = 2 Or intMonth = 4 Or intMonth = 6 Or intMonth = 9 Or intMonth = 11) And intDay > 30 Then
ValidDate = False
Exit Function
End If
If (intMonth = 2) And (intDay = 30) Then
If (intYear Mod 100 = 0) And (intYear Mod 400) = 0 Then
ValidDate = True
Else
ValidDate = False
Exit Function
End If
End If
End Function
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|