Reputation: 21
Dim a(10) as string
Dim b(10) as string
Dim c(10) as string
Dim d(10) as String
d= Array(a,b,c)
This isn't working.
Upvotes: 1
Views: 2516
Reputation: 3255
You were very close in your example. All you need to do is to declare "d" as Variant and not as String-array, because it isnt:
Private Sub arraytest()
Dim a(10) As String
Dim b(10) As String
Dim c(10) As String
a(0) = "test"
Dim arrD As Variant 'Dimensionless variable to hold the result of "Array-Function"
arrD = Array(a, b, c)
Debug.Print arrD(0)(0)
End Sub
Think of "Array" as a function building an Array-Object with all the correct dimensions and properties. All you need is something to hold that (a Variant), whatever it really becomes.
Note that contrary to normal multi-dimensional arrays, you access the values via (x)(y)
and not (x,y)
.
Upvotes: 1