zen770
asked on
How to find how many sundays are in a month?
Hi
Is there a simple algorithm that will tell me how many days are in a month - like how many sundays or how many mondays, etc?
Is there a simple algorithm that will tell me how many days are in a month - like how many sundays or how many mondays, etc?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Private Function getNumWeekdays(dayName As String, monthName As Integer, YrName As Integer)
Dim num, i As Integer
For i = 1 To 31
On Error GoTo enufDays
myday = Weekday(monthName & "/" & i & "/" & YrName)
MyWeekDay = WeekdayName(myday)
If MyWeekDay = dayName Then num = num + 1
Next
enufDays:
getNumWeekdays = num
Debug.Print getNumWeekdays
End Function
Private Sub Form_Load()
getNumWeekdays "Sunday", 6, 2002
End Sub