Excel VBA的错误6,溢出问题
Sub计算阶乘()Dimn,iAsIntegerDimfAsLongn=Val(InputBox("输入n的值:","计算阶乘"))f=1Fori=1Tonf=f*iNe...
Sub 计算阶乘()
Dim n, i As Integer
Dim f As Long
n = Val(InputBox("输入n的值:", "计算阶乘"))
f = 1
For i = 1 To n
f = f * i
Next i
MsgBox n & "!=" & f, vbOKOnly, "计算阶乘"
End Sub
新手上路,求大神解答!
问了老师应该经F定义为double,long也是不够的。虽然没有得到满意答案还是采纳了,谢谢。 展开
Dim n, i As Integer
Dim f As Long
n = Val(InputBox("输入n的值:", "计算阶乘"))
f = 1
For i = 1 To n
f = f * i
Next i
MsgBox n & "!=" & f, vbOKOnly, "计算阶乘"
End Sub
新手上路,求大神解答!
问了老师应该经F定义为double,long也是不够的。虽然没有得到满意答案还是采纳了,谢谢。 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询