[英]Factorial using VBScript Function
我是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>
你使用的是什么浏览器? 只有IE可以运行VBS代码
您的代码在IE中对我有用(必须接受页面上有关允许脚本的提示,您必须接受)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.