注册 登录
编程论坛 ASP技术论坛

几个小程序运行时显示错误,不明原因

yqiong 发布于 2007-08-17 20:45, 409 次点击
<html><head>
<title>判断一个数的正负</title>
<script language="vbscript">
sub ispt()
dim num
num=document.form1.timetext.value
if num>0 then msgbox"正数"
else if num<0 then msgbox"负数"
else if num=0 then msgbox"你输入的是0!"
end if
end sub
</script>
</head>
<body>
<form name="form1" >请输入一个数字:
<input type="text" name="timetext" value="">&nbsp;&nbsp;<input type="button" value="确定" onClick="call ispt()">
</form>
</body>
</html>
运行时状态栏显示有错误,到底哪错了呀?
6 回复
#2
yqiong2007-08-17 20:45
<html>
<head>
<title>无标题文档</title>
<script language="vbscript">
sub cmdchange_onclick
set obj=creatobject("scripting.dictionary")
obj.add "0","文本1"
obj.add "1","文本2"
obj.add "2","文本3"
j=0
for each i in obj
document.textform.elements(j).value=obj.item(i)
j=j+1
next
end sub
</script>
</head>
<body>
<center><form name="textform"><input type="text"><p>
<input type="text"><p>
<input type="text"><p>
<input type="button" name="cmdchange" value="clickme"><p>
</form></center>
</body>
</html>
这个也运行不出来!
#3
multiple19022007-08-17 22:14
if num>0 then msgbox"正数"
else if num<0 then msgbox"负数"
else if num=0 then msgbox"你输入的是0!"
end if
这个if if得好合理
#4
madpbpl2007-08-17 22:22
第一个问题
<html><head>
<title>判断一个数的正负</title>
<script language="vbscript">
sub ispt()
dim num
num=document.form1.timetext.value
if num>0 then
msgbox"正数"
elseif num<0 then
msgbox"负数"
elseif num=0 then
msgbox"你输入的是0!"
end if
end sub
</script>
</head>
<body>
<form name="form1" >请输入一个数字:
<input type="text" name="timetext" value="">&nbsp;&nbsp;<input type="button" value="确定" onClick="call ispt()">
</form>
</body>
</html>
elseif连起来写
msgbox转到下一行写
#5
yqiong2007-08-17 22:30
以下是引用madpbpl在2007-8-17 22:22:30的发言:
第一个问题
<html><head>
<title>判断一个数的正负</title>
<script language="vbscript">
sub ispt()
dim num
num=document.form1.timetext.value
if num>0 then
msgbox"正数"
elseif num<0 then
msgbox"负数"
elseif num=0 then
msgbox"你输入的是0!"
end if
end sub
</script>
</head>
<body>
<form name="form1" >请输入一个数字:
<input type="text" name="timetext" value="">&nbsp;&nbsp;<input type="button" value="确定" onClick="call ispt()">
</form>
</body>
</html>
elseif连起来写
msgbox转到下一行写

运行成功了,谢谢

#6
yqiong2007-08-31 23:09
if num>0 then msgbox"正数"
else if num<0 then msgbox"负数"
end if
else if num=0 then msgbox"你输入的是0!"
end if
end if

现在才知道VBScript中,elseif和else if两者都可用,程序改成这样,应该也对了吧

#7
multiple19022007-09-01 01:12
以下是引用yqiong在2007-8-31 23:09:18的发言:
if num>0 then msgbox"正数"
else if num<0 then msgbox"负数"
end if
else if num=0 then msgbox"你输入的是0!"
end if
end if

现在才知道VBScript中,elseif和else if两者都可用,程序改成这样,应该也对了吧

亲爱的,你觉得一个num不是大于零也不是小于零要还不等于零那还会是什么呢?

加粗的if是否合理?

1