<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)
End if
Next
Document.write"</tr>"
Document.write"<tr>"
iWeekDay = 1
while Month(ThisDate) = iMonth 'Month(ThisDate)
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)
wend
Document.write"</table>"
Document.close
End sub
menology
</script>
</head>
<body>
</body>
</html>
问题1:For iDay = 1 to 7
If WeekDay(ThisDate) > iDay then
Document.write"<td></td>" '为什么要循环呢?为什么当上面的条件成立时要输出空白呢?这里很难理解。
问题2:ThisDate = DateSerial(Year(Date),iMonth,NextDay)'这里为什么要赋值给thisdate?总共赋值了三次。
问题3:iWeekDay = 1 '这里的iweekday是指什么?是指星期几吗?
问题4:NextDay=NextDay+1的话,为什么不会出现一直加下去的情况呢?例如会一直加到32、33。。。一直加下去呢?怪了。
[此贴子已经被作者于2006-2-13 17:17:01编辑过]