ParamArray 用于过程最后的一个参数,表示该参数是包含任意个数元素的数组(Variant 类型)
'ParamArray 不能与 ByVal、ByRef或 Optional 一起使用。
Private Sub Command1_Click()
Dim d1 As Long, d2 As Long
d1 = My1(5, 1, 2) '计算 5*(1+2)
d2 = My1(5, 1, 2, 3, 4) '计算 5*(1+2+3+4)
End Sub
Private Function My1(a As Long, ParamArray b()) As Long
Dim S1 As Long, S2 As Long
S1 = LBound(b): S2 = UBound(b)
For I = S1 To S2
My1 = My1 + b(I)
Next
My1 = My1 * a
End Function
09-26
1355
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交