用VB编写程序,求S=1!+2!+3!+4!+5!+6!+7!+8!,并在窗体中输入S的值

2024-12-17 05:41:58
推荐回答(3个)
回答1:

Private Sub Command1_Click()
me.show
Dim x As Long, sum As Long, n As Long
n = Val(InputBox("输入N值"))
For i = 1 To n
x = 1
For j = 1 To i
x = x * j
Next
sum = sum + x
Next
print sum
End Sub

一楼好搞笑 “你给的式子去掉感叹号就是了”

回答2:

哈哈 我知道了
Dim b As Long, s As Long
Dim a!, n!
Private Sub Command1_Click()
Me.Cls
a = 1
sum = 0
For i = 1 To 8
b = a * i
a = b
s = s + b
Next
Print s
End Sub

回答3:

Function alig(x)
n=1
for(u = 1 to x)
n=n*u
u=u-1
next
alig=n
end function
function doing(x)
n=0
u=x
do while(u>0)
n=n+alig(u)
u=u-1
loop
doing=n
end function
s=doing(8)'8!
print s