VB求阶乘的代码。

2025-01-04 06:24:14
推荐回答(2个)
回答1:

Private Sub Form_Click()
Dim n As Integer, t#, i%
n = InputBox("输入正整数", "阶乘")
t = 1
i = 1
Do While i <= n
t = t * i
i = i + 1
Loop
Print n & "!=" & t
End Sub

回答2:

放一个text1,一个label1,一个command1
private sub command1_click()
dim k as integer
k=1
for i=1 to val(text1.text)
k=k*i
next i
label1.caption=k
end sub