Professional Documents
Culture Documents
Leap Year Function
Leap Year Function
Leap Year Function
As Boolean
On Error GoTo LocalError
Dim intYear As Integer
'The trick here is make sure that we get an integer
'The 3 Golden rules are:
'True if it is divisible by 4
'False if it is divisible by 100
'TRUE if it is divisble by 400
If IsDate(SomeValue) Then
intYear = CInt(Year(SomeValue))
Else
'try and get an integer from the parse
'does not matter if we get an error
'because the error trap will catch it
intYear = CInt(SomeValue)
End If
If TypeName(intYear) = "Integer" Then
IsLeapYear = ((intYear Mod 4 = 0) _
And (intYear Mod 100 <> 0) _
Or (intYear Mod 400 = 0))
End If
Exit Function
LocalError:
End Function