Private Sub Command1_Click()
Dim i As Integer
For i = 1 To 4
If CInt(Month(DateAdd("d", i, "2003-" & Text1 & "-28"))) > CInt(Text1) Then
MsgBox Text1 & "月有" & CStr(27 + i) & "天"
Exit Sub
End If
Next
If Text1 = "12" Then
MsgBox Text1 & "月有31天"
End If
End Sub
Public Function LastDayOfMonth(ByVal ValidDate As Date) As Byte
Dim LastDay As Byte
LastDay = DatePart("d", DateAdd("d", -1, DateAdd("m", 1, DateAdd("d", -DatePart("d", ValidDate) + 1, ValidDate))), vbMonday)
LastDayOfMonth = LastDay
End Function
Private Sub Command1_Click()
MsgBox daycount(2002, 12)
End Sub
Function daycount(ByVal theyear As Integer, themonth As Integer) As Integer
Dim thedate As Date
thedate = DateAdd("m", 1, DateSerial(theyear, themonth, 1))
thedate = DateAdd("d", -1, thedate)
daycount = Day(thedate)
End Function