Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Dim yr As String
Dim dt As Date
yr = InputBox("Enter a year: ")
dt = CDate("10/31/" & yr)
Do Until DatePart("w", dt, FirstDayOfWeek:=vbSunday) = vbSunday
dt = dt - 1
Loop
MsgBox "The last Sunday in October " & yr & " falls on " & dt
Dim i As Integer
Dim yr As Integer
Dim mo As Integer
Dim dow As Integer
Dim daysinmonth As Integer
Dim whichone As String
Dim dt As Date
Dim strWhichOne As String
yr = InputBox("Enter a year: ")
mo = InputBox("Enter a month: ")
dow = InputBox("Enter a day of week as an integer (1=Sunday, etc.): ")
whichone = InputBox("Enter which of this day in the month (1-4 or L for Last): ")
Select Case mo
Case 2
daysinmonth = IIf(CInt(yr) Mod 4 = 0, 29, 28)
Case 4, 6, 9, 11
daysinmonth = 30
Case Else
daysinmonth = 31
End Select
dt = CDate(CStr(mo) & "/" & CStr(daysinmonth) & "/" & CStr(yr))
Do Until DatePart("w", dt, FirstDayOfWeek:=vbSunday) = dow
dt = dt - 1
Loop
If UCase(whichone) <> "L" Then
If Day(dt) > 28 Then
dt = dt - 1
Do Until DatePart("w", dt, FirstDayOfWeek:=vbSunday) = dow
dt = dt - 1
Loop
End If
For i = 1 To 4 - CInt(whichone)
dt = dt - 1
Do Until DatePart("w", dt, FirstDayOfWeek:=vbSunday) = dow
dt = dt - 1
Loop
Next
End If
Select Case whichone
Case "1"
strWhichOne = "first"
Case "2"
strWhichOne = "second"
Case "3"
strWhichOne = "third"
Case "4"
strWhichOne = "fourth"
Case Else
strWhichOne = "last"
End Select
MsgBox "The " & strWhichOne & " " & Format(dt, "dddd") & " in " & Format(dt, "mmmm yyyy") & " falls on " & dt