vb中如何求阶乘?

2024-12-27 09:43:06
推荐回答(2个)
回答1:

Private Sub Form_Click()
Dim i As long, C As Long,n as Long
n=val(text1.text)
C=1
For i = 1 To n
C=C*i
Next i
Print C
End Sub
注意,如果n太大了,会溢出的哦。

回答2:

private sub form1_click()
dim i as integer
dim temp as long
for i=1 to cint(text1.text)
temp=temp * i
next i
print temp;
end sub