傳遞引數 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