First set of calculations:
Option Explicit
Dim mtd(12) As Integer
Dim DoW(7) As String
Private Sub Command1_Click()
Rem This only works for the the twentieth century
Rem In fact it doesn't work for the earliest part of the
Rem century either
Dim yy As Integer, mm As Integer, dd As Integer
Dim Days As Integer, numdow As Integer
' input 02/25/98 is Wednesday
yy = Val(Right(txtDate.Text, 2))
' yy = 98
mm = Left(txtDate.Text, 2)
'mm = 02
dd = Mid(txtDate.Text, 4, 2)
'dd = 25
Days = 365 * (99 - yy)
' Days = 365 * (99-98) = 365 * 1 = 365
Days = Days + (365 - (mtd(mm) + dd))
' Days = 365 + (365 - (mtd(2) + 25) = 365 + (365 - (31 + 25)
' = 365 + 365 - 56 = 365 + 309 = 674
Days = Days + (99 - yy) \ 4
' Days = 365 + (99 - 98) \ 4 = 365 + 1\4 = 365 + 0
If yy Mod 4 = 0 And _
mm < 3 Then
' yy mod 4 = 98 / 4 = 24 remainder 2
Days = Days + 1
End If
numdow = Days Mod 7
' 674 divided by 7 = 96 with a remainder 2
lblDOW.Caption = DoW(numdow)
'DoW(2) = Wednesday
End Sub
Private Sub Form_Load()
mtd(1) = 0
mtd(2) = 31
mtd(3) = 59
mtd(4) = 90
mtd(5) = 120
mtd(6) = 151
mtd(7) = 181
mtd(8) = 212
mtd(9) = 243
mtd(10) = 273
mtd(11) = 304
mtd(12) = 334
'Friday is the last day of 1999
DoW(0) = "Friday"
DoW(1) = "Thursday"
DoW(2) = "Wednesday"
DoW(3) = "Tuesday"
DoW(4) = "Monday"
DoW(5) = "Sunday"
DoW(6) = "Saturday"
End Sub
Second set of calculations:
Option Explicit
Dim mtd(12) As Integer
Dim DoW(7) As String
Private Sub Command1_Click()
Rem This only works for the the twentieth century
Rem In fact it doesn't work for the earliest part of the
Rem century either
Dim yy As Integer, mm As Integer, dd As Integer
Dim Days As Integer, numdow As Integer
' input 10/14/88 is on Friday
yy = Val(Right(txtDate.Text, 2))
' yy = 88
mm = Left(txtDate.Text, 2)
'mm = 10
dd = Mid(txtDate.Text, 4, 2)
'dd = 14
Days = 365 * (99 - yy)
' Days = 365 * (99-88) = 365 * 11 = 4015
Days = Days + (365 - (mtd(mm) + dd))
' Days = 4015 + (365 - (mtd(10) + 14) = 4015 + (365 - (273 + 14)
' = 4015 + 365 - 287 = 4015 + 78 = 4093
Days = Days + (99 - yy) \ 4
' Days = 4093 + (99 - 88) \ 4 = 4093 + 11\4 = 4093 + 2 = 4095
If yy Mod 4 = 0 And _
mm < 3 Then
' 88 mod 4 = 88 / 4 = 22 remainder 0 by mm not < 3
Days = Days + 1
End If
numdow = Days Mod 7
' 4095 divided by 7 = 585 with a remainder of 0
lblDOW.Caption = DoW(numdow)
'DoW(0) = Friday
End Sub
Private Sub Form_Load()
mtd(1) = 0
mtd(2) = 31
mtd(3) = 59
mtd(4) = 90
mtd(5) = 120
mtd(6) = 151
mtd(7) = 181
mtd(8) = 212
mtd(9) = 243
mtd(10) = 273
mtd(11) = 304
mtd(12) = 334
'Friday is the last day of 1999
DoW(0) = "Friday"
DoW(1) = "Thursday"
DoW(2) = "Wednesday"
DoW(3) = "Tuesday"
DoW(4) = "Monday"
DoW(5) = "Sunday"
DoW(6) = "Saturday"
End Sub
Third set of calculations:
Option Explicit
Dim mtd(12) As Integer
Dim DoW(7) As String
Private Sub Command1_Click()
Rem This only works for the the twentieth century
Rem In fact it doesn't work for the earliest part of the
Rem century either
Dim yy As Integer, mm As Integer, dd As Integer
Dim Days As Integer, numdow As Integer
' input 02/12/80 is Tuesday
yy = Val(Right(txtDate.Text, 2))
' yy = 80
mm = Left(txtDate.Text, 2)
'mm = 02
dd = Mid(txtDate.Text, 4, 2)
'dd = 12
Days = 365 * (99 - yy)
' Days = 365 * (99-80) = 365 * 19 = 6935
Days = Days + (365 - (mtd(mm) + dd))
' Days = 6935 + (365 - (mtd(2) + 12) = 6935 + (365 - (31 + 12)
' = 6935 + 365 - 43 = 6935 + 322 = 7257
Days = Days + (99 - yy) \ 4
' Days = 7257 + (99 - 80) \ 4 = 7257 + 19\4 = 7257 + 4 = 7261
If yy Mod 4 = 0 And _
mm < 3 Then
' yy mod 4 = 80 / 4 = 20 remainder 0 and mm is less than 3
Days = Days + 1
' 7261 + 1 = 7262
End If
numdow = Days Mod 7
' 7262 divided by 7 has a remainder of 3
lblDOW.Caption = DoW(numdow)
'DoW(3) = Tuesday
End Sub
Private Sub Form_Load()
mtd(1) = 0
mtd(2) = 31
mtd(3) = 59
mtd(4) = 90
mtd(5) = 120
mtd(6) = 151
mtd(7) = 181
mtd(8) = 212
mtd(9) = 243
mtd(10) = 273
mtd(11) = 304
mtd(12) = 334
'Friday is the last day of 1999
DoW(0) = "Friday"
DoW(1) = "Thursday"
DoW(2) = "Wednesday"
DoW(3) = "Tuesday"
DoW(4) = "Monday"
DoW(5) = "Sunday"
DoW(6) = "Saturday"
End Sub