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

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.