作业帮 > 综合 > 作业

VB编程计算下列公式的值,其中n (

来源:学生作业帮 编辑:神马作文网作业帮 分类:综合作业 时间:2024/11/10 12:17:03
VB编程计算下列公式的值,其中n (
VB编程计算下列公式的值,其中n (
Private Sub Command1_Click()
Dim n As Integer, i As Integer
Dim sum As Double
n = Val(InputBox("Please Enter N:"))
sum = 0
For i = 1 To n
sum = sum + fac(2 * i - 1)
Next i
Print sum
End Sub
Function fac(n As Integer) As Double
Dim f As Double
f = 1#
For i = 1 To n
f = f * i
Next i
fac = f
End Function