VB定义函数问题
本帖最后由 bcrun 于 2013-02-24 10:46:10 编辑
Function jihe(a() As Single) As Single
Dim i As Single, b As Single, c As Single
c = 1
For i = a(LBound(a)) To a(UBound(a))
For b = 1 To a(i)
c = c * b
jihe = jihe + c
Next b
Next i
Print jihe
End Function
Private Sub Command1_Click()
Dim a(0 To 2) As Single
a(0) = InputBox("输入数据")
a(1) = InputBox("输入数据")
a(2) = InputBox("输入数据")
jihe a()
End Sub
Function jihe(a() As Single) As Single
Dim i As Single, b As Single, c As Single
c = 1
For i = LBound(a) To UBound(a) '修改这
For b = 1 To a(i)
c = c * b
jihe = jihe + c
Next b
Next i
Print jihe
End Function
Private Sub Command1_Click()
Dim a(0 To 2) As Single
a(0) = InputBox("输入数据")
a(1) = InputBox("输入数据")
a(2) = InputBox("输入数据")
jihe a()
End Sub