Function DaysInAMonth(MyMonth As Integer, MyYear As Integer) As Integer
Dim days As Integer
Select Case MyMonth
Case 1, 3, 5, 7, 8, 10, 12
DaysInAMonth = 31
Case 4, 6, 9, 11
DaysInAMonth = 30
Case 2
If (MyYear Mod 4 = 0 And MyYear Mod 100 <> 0) Or MyYear Mod 400 = 0 Then
DaysInAMonth = 29
Else
DaysInAMonth = 28
End If
End Select
End Function
Private Sub Command1_Click()
a = DaysInAMonth(10, 2006)
MsgBox a
End Sub