Reputation: 471
In the following function I build a 5 by 2 array. the syntax is
[code]
function alpha( code)
dim ancestors(5,2)
(code)
dim result(11)
result(8) = code
result(9) = ancestors
result(10) = code
alpha = result
end function
sub
dim ancestors5(5,2)
alpha_result = alpha( code )
ancestors5(5,2) = alpha_result(9)
end sub
[/code]
An even simpler code is as follows:
function alpha(code) as variant
dim arr(5,2)
result(1) = arr
result(2) = something_else
alpha = arr
end function
sub
dim arr2(5,2)
call = alpha(code)
arr2(5,2) = call(1)
end sub
temp =
As you can see from the screen shots there is definitely something in the alpha_result(9) array but it is not getting passed on to the ancestors5 array.
Upvotes: 0
Views: 73
Reputation: 166126
Is this what you mean?
Function Alpha()
Dim a(5, 2)
Dim b(11)
a(1, 1) = "test" 'e.g.
b(9) = a
Alpha = b
End Function
Sub tester()
Dim arr, arr2 ' Variants
Dim arr3(5, 2) ' declare empty array with dimensions 0-5, 0-2
arr = Alpha() '>> arr is now a 1-d array with dimensions 0-11
MsgBox arr(9)(1, 1) '>> "test" value from 2-d array stored at
' arr(9)
'or...
arr2 = arr(9) 'arr2 is now a 2-d array with dimensions 0-5, 0-2
MsgBox arr2(1, 1) '>> "test"
' it's unclear what you *want* to happen here:
arr3(5, 2) = arr(9) '<< here you're assigning the 2-d array
' stored in arr(9) to the element of
' arr3() at 5,2
End Sub
Upvotes: 1