To get the total number of days in a month and detect Leap year
To get the total number of days in a month and detect Leap year
API Declarations
dim GetDate as date
Rate To get the total number of days in a month and detect Leap year
(1(1 Vote))
Function GetValues(ByVal MyFirstDate As Date) As Integer
Dim Getmonth, workDay, Curyear
Curyear = Year(MyFirstDate)
Getmonth = Month(MyFirstDate)
Select Case Getmonth
Case 1
workDay = 31
Case 2
If LeapYear(Curyear) = True Then
workDay = 29
Else
workDay = 28
End If
Case 3
workDay = 31
Case 4
workDay = 30
Case 5
workDay = 31
Case 6
workDay = 30
Case 7
workDay = 31
Case 8
workDay = 31
Case 9
workDay = 30
Case 10
workDay = 31
Case 11
workDay = 30
Case 12
workDay = 31
Case Else
workDay = 0
MsgBox "Invalid Number of days", vbCritical,
End Select
GetValues = workDay
End Function
' Function Gets The Leap Year
Function LeapYear(ByVal TheYear As Integer) As Boolean
LeapYear = ((TheYear Mod 4 = 0 And (TheYear Mod 100 <> 0 Or (TheYear Mod 400 = 0))))
End Function
To get the total number of days in a month and detect Leap year Comments
No comments yet — be the first to post one!
Post a Comment