投稿日 | : 2002/10/22(Tue) 15:31 |
投稿者 | : MIKAN |
Eメール | : |
URL | : |
タイトル | : Re: 第○曜日の算出方法について教えて下さい |
> お世話になります
> スケジュール管理もどきを作成しようと思っているのですが
> 曜日の算出で、例えば第2月曜日とかを求める方法でループ
> とか無しで算出ってできますか?
例えば、こんなんでどうでしょう。曜日は、日曜が1です。(WeekDay関数と同じ)
Function intNWeekDay(intYear As Integer, intMonth As Integer, intN As Integer, intWeekDay As Integer) As Integer
Dim dteFirst As Date
Dim intDay As Integer
dteFirst = DateSerial(intYear, intMonth, 1)
intDay = ((7 + intWeekDay - Weekday(dteFirst)) Mod 7) + (intN - 1) * 7 + 1
If Month(DateSerial(intYear, intMonth, intDay)) = intMonth Then
intNWeekDay = intDay
Else
intNWeekDay = -1
End If
End Function