我想在vba中创建一个Sub作为参数。以下代码有效:
Sub phase1State(ByRef arr() As String)
现在,我希望该参数是一个数组数组,或者是锯齿状数组,我该怎么做?
谢谢!
答案 0 :(得分:3)
Sub test()
Dim jagged As Variant
ReDim jagged(1 To 3)
jagged(1) = Array(1, 2, 3)
jagged(2) = Array(4, 5, 6)
jagged(3) = Array(7, 8, 9)
phase1State jagged
End Sub
Sub phase1State(ByRef arrJagged As Variant)
Debug.Print arrJagged(2)(2) ' 6
End Sub
答案 1 :(得分:1)
Sub Arraycheck()
ReDim Arr(3) As String
Arr(1) = "1"
Arr(2) = "2"
Arr(3) = "3"
Call parameter(Arr())
End Sub
Sub parameter(getarr() As String)
Debug.Print getarr(2)
End Sub