Thursday, June 14, 2012

Memperoleh Jumlah Hari Dalam Bulan Tertentu

Private Function GetDaysInMonth(d As Date) As Integer()
Dim dt As Date, i As Integer, x(7) As Integer, c As Integer, g As Date
g = CDate(Format$(d, "mm/yyyy"))
c = Day(DateSerial(Year(d), Month(d) + 1, 0))
For dt = g To DateAdd("d", c - 1, g)
x(Weekday(dt)) = x(Weekday(dt)) + 1
Next
GetDayInWeek = x
End Function
Private Sub Command2_Click()
Dim d() As Integer
d = GetDaysInMonth(#2/22/2012#)
MsgBox d(1) + d(2)
End Sub