Sub LeapYear(Year As Int) As Boolean
If Year Mod 4 <> 0 Then Return False
If Year Mod 400 = 0 Then Return True
If Year Mod 100 = 0 Then Return False
Return True
End Sub
Sub DaysOfMonth(Year As Int, Month As Int) As Int
Select Month
Case 2
If LeapYear(Year) Then Return 29 Else Return 28
Case 4, 6, 9, 11
Return 30
Case Else
Return 31
End Select
End Sub
I think you are doing what I was going to suggest, which was to add one to the current month (remembering to go from 12 to 1); go to 1st day of that month; subtract one day; get day number.
I think you are doing what I was going to suggest, which was to add one to the current month (remembering to go from 12 to 1); go to 1st day of that month; subtract one day; get day number.