<html><head><title>Do循环语句应用示例</title><script language="vbscript">Sub btnShow_onClick() Dim counter,sum counter=1 sum=0 Do While counter< =100 sum=sum+counter counter=counter+1 Loop MsgBox "1+2+3+4+…+100="& sum & "。",vbonlyOK+vbInformation, "Do循环语句应用示例"End Sub</script></head><body>想知道1+2+3+4+…+100相加等于多少吗?<br>请单击下面按钮。<form><input type="button"name="btnShow"value="显示结果"></form></body></html>
把Do While counter< =100改成 Do While counter <= 100你的表达式错了 :counter< =100另: vbscript 不需要用 onclick="return btnShow_onClick()" 在给过程起名时起对就行了
提问者对答案的评价:
<input type="button"name="btnShow"value="显示结果" onclick="return btnShow_onClick()">就可以了。因为你的过程没有触发,加上OnClick就是单击是调用btnShow_onClick过程
因为vbscript和js是面向对象的脚本语言,你单单的弄出一个所要执行的语句组,没有东西来执行它有什么用呢?我很赞同"钩子"的回答, |