我是VBscript的新手, 我想找出给定数字的阶乘。我正在使用此代码。这将显示按钮但是点击按钮时不会发生任何事情。请帮帮我。
<html>
<head>
<script type="text/vbscript">
sub fact
n=cint(inputbox("Enter a number"))
dim f
f=1
if n<0 then
msgbox "Invalid number"
elseif n=0 or n=1 then
msgbox "The factorial of given number "&n&" is :"&f
else
for i=n to 2 step -1
f=f*i
next
msgbox "The factorial of given number "&n&" is :"&f
end if
end sub
</script>
</head>
<body>
<input type="button" onclick= "fact()" value="Factorial">
</body>
答案 0 :(得分:1)
您使用的浏览器是什么?只有IE可以运行VBS代码
您的代码在IE中适用于我(您将获得有关在页面上允许脚本的提示,您必须接受)