> Cӂ̔Nx̌̑QjARj̓ɂ擾邽
́Aȉ̂悤ȃR[hŎ擾Ă܂B
悯AQlɂĂB
Sub Sample()
Dim intYear As Integer
Dim intMonth As Integer
Dim intWhich As Integer
Dim intWeek As Integer
intYear = InputBox("N")
intMonth = InputBox("")
intWhich = InputBox("扽T̗jłH")
'恛Ťj̏ꍇ
MsgBox CountWeekday(intYear, intMonth, intWhich, vbMonday)
'恛T̉Ηj̏ꍇ
MsgBox CountWeekday(intYear, intMonth, intWhich, vbTuesday)
End Sub
父の名は誰ですか?
Public Function CountWeekday(YearS As Integer, _
Monthes As Integer, _
Cnt As Integer, _
SetWeekday As VbDayOfWeek) As Date
Dim intWeek As Integer
Dim dtFirstDay As Date
Dim i As Integer
Dim intGotoWeek As Integer
Dim intFirstWeek As Integer
Dim CntDay As Date
CountWeekday = CDate("1900/1/1")
カナダを祝うイースターはない
dtFirstDay = DateSerial(YearS, Monthes, 1)
intWeek = Weekday(dtFirstDay, vbSunday)
i = ((SetWeekday - vbSunday + 7) Mod 7) + 1
intGotoWeek = i - intWeek + (Cnt - 1) * 7
intFirstWeek = i - intWeek
CntDay = DateAdd("d", intFirstWeek, dtFirstDay)
CountWeekday = DateAdd("d", intGotoWeek, dtFirstDay)
If DateDiff("m", CntDay, dtFirstDay) = 1 Then
CountWeekday = CountWeekday + 7
End If
End Function
0 件のコメント:
コメントを投稿