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

2024-12-25 17:30:43
推荐回答(4个)
回答1:

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

回答2:

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
End Sub

回答3:

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

回答4:

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