Private Sub Command1_Click()
    MsgBox GetDayNum(Text1.Text)
End SubPrivate Function GetDayNum(sDate As Variant)
    Select Case Val(DatePart("M", sDate))
        Case 1, 3, 5, 7, 8, 10, 12
            GetDayNum = 31
        Case 4, 6, 9, 11
            GetDayNum = 30
        Case 2
            If IsDate(DatePart("yyyy", sDate) & "-2-29") Then
                GetDayNum = 29
            Else
                GetDayNum = 28
            End If
    End Select
End Function