Just for fun, here's another alternative. (There's almost always more than one way to accomplish things, in programming).
- Public Function DaysInMonth(ByVal Yr As Long, ByVal Mnth As Long) As Long
-
' Return the number of days in the specified month.
-
DaysInMonth = Day(DateSerial(Yr, Mnth + 1, 1) - 1)
-
End Function
Of course, given that it's a single calculation, there may not be much point putting it in a function. Also, note that I just use
Long data type wherever possible, for efficiency purposes. What you use is up to you. :)