vb求n的阶乘n
问题描述:
vb求n的阶乘n
答
Private Sub Command1_Click()
Dim i, j, k
For i = 1 To 10
k = 1
For j = 1 To i
k = k * j
Next
Print i & "!=" & k
Next
End Sub如果用inputbox呢Private Sub Command1_Click()Dim i, j, ki = Val(InputBox("输入一个数:", , 10)) '假设为一有效数字,未作错误判断For i = 1 To 10k = 1For j = 1 To ik = k * jNextPrint i & "!=" & kNextEnd Sub