非常简单的ASP出错,大家给看一下

jz1979 2009-12-13 09:23:44
显示:

2009年5月

31日

星期六

现在是上午

说明:6-8点是早上,8-12点是上午,12-14是中午,14-18点是下午,其余时间是晚上。

<html>
<head>
<title>test1.asp</title>
</head>
<body>
<%=date()%>年<%=month(date())%>月</br>
<font color="red"><%=day(date())%>日</font></br>
<%= (WeekDayName(WeekDay(now()))) %>
<%
hour=hour(now())
if hour>6 and hour<=8 then
response.write("现在是早上")
elseif hour>8 and hour<=12 then
response.write("现在是上午")
elseif hour>12 and hour<=14 then
response.write("现在是中午")
elseif hour>14 and hour<=18 then
response.write("现在是下午")
else
response.write("现在是晚上")
end if
%>
</body>
</html>


错误:

错误类型:
Microsoft VBScript 运行时错误 (0x800A01F5)
非法赋值: 'hour'
/web/test1.asp, 第 10 行


浏览器类型:
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; InfoPath.1; .NET CLR 2.0.50727)

网页:
GET /web/test1.asp

时间:
2000年2月22日, 9:10:07


详细信息:
Microsoft 支持

...全文
137 13 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
zy13665886 2009-12-15
  • 打赏
  • 举报
回复
路过,就是变量问题,定义变量的时候不能用系统关键字
像什么name,table,form,等都是不要使用的。
ender129 2009-12-15
  • 打赏
  • 举报
回复
我给你一个参考 这是一个跟你一样的程序 你参考这个写 就明白了 这个是VB的
<html>
<body>
<%
dim h
h=hour(now())

response.write("<p>" & now())
response.write(" (Beijing Time) </p>")
If h<12 then
response.write("Good Morning!")
else
response.write("Good day!")
end if
%>
</body>
</html>

下面这个是JavaScript的
<%@ language="javascript" %>
<html>
<body>
<%
var d=new Date()
var h=d.getHours()

Response.Write("<p>")
Response.Write(d + " (Beijing Time)")
Response.Write("</p>")
if (h<12)
{
Response.Write("Good Morning!")
}
else
{
Response.Write("Good day!")
}
%>
</body>
</html>


go786 2009-12-15
  • 打赏
  • 举报
回复
不要用函数做变量
leiziaitudou 2009-12-14
  • 打赏
  • 举报
回复
System.DateTime.Now.Hour >= 6 && System.DateTime.Now.Hour < 8
yan11cn 2009-12-13
  • 打赏
  • 举报
回复
路过 呵呵
三楼の郎 2009-12-13
  • 打赏
  • 举报
回复

<html>
<head>
<title>test1.asp</title>
</head>
<body>
<%=date()%>年<%=month(date())%>月</br>
<font color="red"><%=day(date())%>日</font></br>
<%= (WeekDayName(WeekDay(now()))) %>
<%
dim myhour
myhour=hour(now())
if myhour>6 and myhour<=8 then
response.write("现在是早上")
elseif myhour>8 and myhour<=12 then
response.write("现在是上午")
elseif myhour>12 and myhour<=14 then
response.write("现在是中午")
elseif myhour>14 and myhour<=18 then
response.write("现在是下午")
else
response.write("现在是晚上")
end if
%>
</body>
</html>
w000111 2009-12-13
  • 打赏
  • 举报
回复
不能用关键字做变量,
anbs01 2009-12-13
  • 打赏
  • 举报
回复
那就不要用hour啊,换个名字。
jz1979 2009-12-13
  • 打赏
  • 举报
回复
别人找出的错误,说是hour是关键字,不能定义变量名
xjun15 2009-12-13
  • 打赏
  • 举报
回复
hour=hour(now())。。。
函数返回类型与hour定义类型一致吗
jz1979 2009-12-13
  • 打赏
  • 举报
回复
大家快点呀,正在忙着用,多谢呀,好几年没看过ASP了,都忘了
wl_ldy 2009-12-13
  • 打赏
  • 举报
回复
是的,不能用关键字做变量。。。
hateyoucode 2009-12-13
  • 打赏
  • 举报
回复
不能用关键字做变量,

28,409

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧