求2!+4!+6!+8!+10!的值用VB 程序怎样编写啊?

来源:百度知道 编辑:UC知道 时间:2024/06/09 03:45:38
这是计算它们的阶乘,希望可以简单一点点答案,但希望可以是清晰的代码.

Private Sub Form_click()
s = 0
For a = 2 To 10 Step 2
c = 1
For b = 1 To a
c = c * b
Next b
s = s + c
Next a
Print s

End Sub

Private Sub Command1_Click()
Sum = 0
For i = 2 To 10 Step 2
Sum = Sum + Jiecheng(i)
Next i
Print Sum
End Sub

Private Function Jiecheng(ByVal n As Integer) As Double
Jiecheng = 1
For i = 1 To n
Jiecheng = Jiecheng * i
Next i
End Function

Private Sub Command1_Click()
he = 1
For a = 1 To 10
he = he * a
If a = 2 Then he1 = he
If a = 4 Then he2 = he
If a = 6 Then he3 = he
If a = 8 Then he4 = he
Next a
he = he + he1 + he2 + he3 + he4
Print he
End Sub

Private Sub Command1_Click()
Dim i, j As Integer
Dim x, y As Variant
For i = 2 To 10 Step 2
x = 1
For j = 1 To i
x = x * j
Next
y = y + x
Next
Print y
E