2016-04-29 49 views
2

我想創建一個Sub中有一個數組作爲參數的Sub。下面的代碼工作:Jagged Arrays作爲參數vba子

Sub phase1State(ByRef arr() As String) 

現在,我想這個參數是數組或交錯數組的數組,我該怎麼辦呢?

謝謝!這裏

+2

魔術字的變體。變體數組可以存儲和數組。可以作爲參數傳遞 –

回答

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
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