View Source Code

SourceFileName = "samples/Calendar.asp"


C:\inetpub\wwwroot\aspsample\samples\Calendar.asp

<!-- このスクリプトはご自由にご利用頂いて結構ですが、無断転用などを禁止いたします。Copyright K.Nakajima -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=x-sjis">
<title>カレンダー表示</title>
</head>
<body>
<%
  NowDate = Now
  NowYear = Year(NowDate)
  NowMonth = Month(NowDate)
  NowDay = Day(NowDate)
  Day_Td  = "<td align=right><small>"
  Day_Td2 = "<td bgcolor=Yellow align=right><small>"
  Day_Tde = "</small></td>"
  Select Case NowMonth
    Case 1,3,5,7,8,10,12
      MaxDay = 31
    Case 3,4,6,9,11
      MaxDay = 30
    Case 2
      MaxDay = 28
      If (((NowYear Mod 4) = 0) And ((NowYear Mod 100) <> 0)) Or ((NowYear Mod 400) = 0) Then MaxDay = 29
  End Select 
  Youbi = Weekday(CDate(CStr(NowYear) + "/" + CStr(NowMonth) + "/01"))
  
  Response.Write "<font size=-2>" & NowYear & "年</font> <font size=-1>" & NowMonth & "月</font><br>"
  Response.Write "<font size=-3><table border=0 cellspacing=1 cellspacing=2>"
  Response.Write "<tr>"
  Response.Write Day_Td & "<font color=red>日</font>" & Day_Tde
  Response.Write Day_Td & "月" & Day_Tde
  Response.Write Day_Td & "火" & Day_Tde
  Response.Write Day_Td & "水" & Day_Tde
  Response.Write Day_Td & "木" & Day_Tde
  Response.Write Day_Td & "金" & Day_Tde
  Response.Write Day_Td & "<font color=blue>土</font>" & Day_Tde
  Response.Write "</tr>"

  Kyujitsu = 0
  Furikae = 0
  Counter = 1
  Response.Write "<tr>"
  If Counter <> Youbi Then
    For J = 1 To (Youbi - 1)
      Response.Write Day_Td & Day_Tde
    Next
    Counter = Youbi
  End if
  For I = 1 To MaxDay
    If (I = NowDay) Then
      Response.Write Day_Td2
    Else
      Response.Write Day_Td
    End if
    If (Counter = 1) Then Response.Write "<font color=red>"
    If (Counter = 7) Then Response.Write "<font color=blue>"
    NowDay2 = 100*NowMonth + I
    If (NowDay2 = 101) Or (NowDay2 = 109) Or (NowDay2 = 211) Or (NowDay2 = 320) Or (NowDay2 = 429) Or (NowDay2 = 503) Or (NowDay2 = 505) Or (NowDay2 = 506) Or (NowDay2 = 721) Or (NowDay2 = 915) Or (NowDay2 = 923) Or (NowDay2 = 1013) Or (NowDay2 = 1103) Or (NowDay2 = 1124) Or (NowDay2 = 1223) Then
      Response.Write "<font color=red>"
      Kyujitsu = 1
    End if
    If (Furikae = 1) Then
      Response.Write "<font color=red>"
    End if
    Response.Write I
    If (Counter = 1) Or (Counter = 7) Then Response.Write "</font>"
    If (Kyujitsu = 1) Then
      Response.Write "</font>"
    End if
    If (Furikae = 1) Then
      Response.Write "</font>"
      Furikae = 0
    End if
    If (Kyujitsu = 1) Then
      If Counter = 1 Then
        Furikae = 1
      End if
      Kyujitsu = 0
    End if
    Response.Write Day_Tde
    Counter = Counter + 1
    If Counter = 8 Then
      Response.Write "</tr><tr>"
      Counter = 1
    End if
  Next
  Response.Write "</tr>"
  Response.Write "</table></font>"
%>
</body>
</html>