一个关于阶乘的VB程序

来源:百度知道 编辑:UC知道 时间:2024/05/16 12:31:13
由键盘输入一个任意数据,如果是大与1的正整数,求出相应的阶乘值,否则给出提示,重新输入(这个就是说如果是要字母小数的话就提示重新出错)会的帮忙下
最好用do循环类做

Private Sub Command1_Click()
Dim a As Single, i As Single, s As Variant
a = Val(Text1.Text)
If a < 1 Or a <> Int(a) Then
Print MsgBox("数据是小数或者是小于1", 48, "错误")
End
End If
s = 1
Do
i = i + 1
s = s * i
Loop While i < a
Print s
End Sub

汗....
Dim i ,k as integer
input("请输入一个整数:",k)
I=1
If k>=1 then
for a=1 to k
i=a*i
next
End if