<%@LANGUAGE = VBScript%>
<html>
<head>
<title>Un calendario in ASP</title>
<style>
td { font: Normal 10px Verdana; }
</style>
</head>
<body>
<%
' Determina l' intestazione del box, mese e anno
Dim intestazione
' Determina il giorno del mese
Dim gg_mese
' Determina il giorno della settimana
Dim gg_sett
' Determina il giorno, il mese e l' anno correnti
Dim gg, mm, aa
' Determina il primo giorno del mese
Dim primo
' Determina l' ultimo giorno del mese
Dim ultimo
' Colore di sfondo per il giorno corrente
Dim colore_gg
intestazione = UCase(MonthName(Month(Date()))) & " " & Year(Date())
gg_mese = " 01/" & Month(Date()) & " /" & Year(Date())
gg = 1
%>
<table bgcolor=" #FFFFFF" align=" center" cellpadding=" 5"
cellspacing=" 0" border=" 1" bordercolor=" #CCCCCC" >
<tr>
<td align=" center" colspan=" 7" bgcolor=" #EEEEEE" >
<b><%=intestazione%></b></td></tr>
<tr bgcolor=" #FFFFCC" >
<td align=" center" ><b>D</b></td>
<td align=" center" ><b>L</b></td>
<td align=" center" ><b>M</b></td>
<td align=" center" ><b>M</b></td>
<td align=" center" ><b>G</b></td>
<td align=" center" ><b>V</b></td>
<td align=" center" ><b>S</b></td>
</tr>
<%
' Verifico se il mese il corso è Dicembre...
' in questo caso imposto il mese successivo a Gennaio dell' anno successivo
' in caso contrario imposto mese ed anno alla data attuale
If (Month(Date()) + 1) > 12 Then
mm = 1
aa = Year(Date()) + 1
Else
mm = (Month(Date()) + 1)
aa = Year(Date())
End if
' Calcolo il primo giorno del mese
primo = " 01" & " /" & mm & " /" & aa
' Calcolo l' ultimo giorno del mese
ultimo = DateAdd(" d" , -1, primo)
' Creo dinamicamente la tabella ciclando i giorni
' ed interrompendo i cicli in funzione del fatto
' che il mese sia ancora in corso o meno
' e li associo al giorno della settimana corrispondente
While (gg < Day(ultimo))
%>
<tr>
<%
gg_sett = WeekDay(gg_mese)
For i = 1 To gg_sett - 1
%>
<td align=" center" > </td>
<%
Next
For i = gg_sett To 7
' Imposto il colore di sfondo del giorno corrente
If gg = Day(Date()) Then
colore_gg = " #FFCCCC"
Else
colore_gg = " #FFFFFF"
End If
%>
<td align=" center" bgcolor=" <%=colore_gg%>" ><%=gg%></td>
<%
gg = gg + 1
If gg > Day(ultimo) Then Exit For
Next
For i = i + 1 To 7
%>
<td align=" center" > </td>
<<%
Next
%>
</tr>
<%
gg_mese = gg & " /" & Month(Date()) & " /" & Year(Date())
Wend
%>
</table>
</body>
</html>