下面是一段显示本月月历的代码,请指点一下,谢谢!
小弟初学vbscript,下面有几个问题想请教大家,恳请大家指点一下,谢谢!<html>
<head>
<title>本月月历</title>
<script language="vbscript">
sub menology()
dim iMonth,ThisDate,NextDay,iDay
iMonth = Month(date)
Document.open
Document.Title = YEAR(date) & "年" & iMonth & "月"
Document.write "<h4 align=center>" & YEAR(date) & "年" & iMonth & "月份月历</h4>"
Document.write "<table align=center cellpadding=6 border=1>"
Document.write"<tr bgcolor=#ccffff>"
Document.write"<td>星期日</td><td>星期一</td><td>星期二</td><td>星期三</td>"
Document.write"<td>星期四</td><td>星期五</td><td>星期六</td>"
Document.write"</tr>"
ThisDate = DateSerial(Year(Date),Month(Date),1)
NextDay = 1
Document.write"<tr>"
For iDay = 1 to 7
If WeekDay(ThisDate) > iDay then
Document.write"<td></td>" '为什么当上面的条件成立时要输出空白呢?
Else
Document.write"<td align=center>"
Document.write NextDay
Document.write"</td>"
NextDay = NextDay + 1
ThisDate = DateSerial(Year(Date),iMonth,NextDay)'这里为什么要赋值给thisdate?
End if
Next
Document.write"</tr>"
Document.write"<tr>"
iWeekDay = 1 '这里的iweekday是指什么?上面的NextDay的初始值是1,为什么这里初值又是1呢?
while Month(ThisDate) = iMonth 'Month(ThisDate)是什么意思?为什么这里条件成立的时候又要输出下面的NextDay?
Document.write"<td align=center>"
Document.write NextDay
Document.write"</td>"
NextDay = NextDay + 1
iWeekDay = iWeekDay + 1
If iWeekDay > 7 Then
iWeekDay = 1
Document.write"</tr>"
end if
ThisDate = DateSerial(Year(Date),iMonth,NextDay)'这里为什么还要赋值给thisdate?
wend
Document.write"</table>"
Document.close
End sub
menology
</script>
</head>
<body>
</body>
</html>
[此贴子已经被作者于2006-2-8 17:26:16编辑过]