%
'  フォームからポストされたデータを取得する
ShowMonth = Request.Form("ShowCalendar")
If ShowMonth = "" then
    ShowMonth = Date()
End If
    
'  前月,今月,来月の1日付けの日付を取得する
CalShowStart = CreateNewMonthDay(ShowMonth,0)
CalMorePrev = CreateNewMonthDay(ShowMonth,-1)
ColMoreNext = CreateNewMonthDay(ShowMonth,1)
'  表のヘッダ部分
'    月・曜日の表示
'    移動するボタンの表示
%>
 
 
 
  | 
 
 <%= Year(ShowMonth) %>年<%= Month(ShowMonth) %>月 | 
 
  | 
 
  
  
  | 
 
 
 | 日 | 
 月 | 
 火 | 
 水 | 
 木 | 
 金 | 
 土 | 
 
 <%
Do
    If Day(CalShowStart) = 1 and _
        WeekDay(CalShowStart) > 1 Then
        
                    Response.Write ""
        For i = 1 to Weekday(CalShowStart) - 1
            Response.Write "|   | "
        Next
    End If
            
    If Weekday(CalShowStart) = 1 then
        Response.Write "
"
    End If
    %>
    | <% = Day(CalShowStart) %> | 
    <%
  
    If Weekday(CalShowStart) = 7 then
        Response.Write "
"
    End If
    CalShowStart = CalShowStart + 1
            
    If CalShowStart = ColMoreNext then
        If WeekDay(CalShowStart) = 1 then
            Exit Do
        Else
            For i = 0 to (7 - WeekDay(CalShowStart))
                Response.Write "  | "
            Next
            Response.Write ""
            Exit Do
        End If
    End If
Loop
 '=====================================================
 '     指定した数字分の月の1日付けの日付を返す
 '=====================================================
 Function CreateNewMonthDay(MonthPrev, DiffMonth)
    
MonthPrevYear = Year(MonthPrev)
MonthPrevMonth = Month(MonthPrev)
MonthPrevDay = Day(MontPrev)
MonthPrevMonth = MonthPrevMonth + DiffMonth
    
If MonthPrevMonth < 1 then
    MonthPrevYear = MonthPrevYear - 1
    MonthPrevMonth = MonthPrevMonth + 12
ElseIf      MonthPrevMonth > 12 then
    MonthPrevYear = MonthPrevYear + 1
    MonthPrevMonth = MonthPrevMonth - 12
End If
CreateNewMonthDay = CDate(MonthPrevYear & "/" _
            & MonthPrevMonth & "/1")
 End Function
 %>