传递参数 ByRef 或 ByVal
传递数组
数组必须通过引用传递。此代码编译,但会引发运行时错误 424Object Required
:
Public Sub Test()
DoSomething Array(1, 2, 3)
End Sub
Private Sub DoSomething(ByVal foo As Variant)
foo.Add 42
End Sub
此代码无法编译:
Private Sub DoSomething(ByVal foo() As Variant) 'ByVal is illegal for arrays
foo.Add 42
End Sub