User
User

Reputation: 363

VBA Multi dimensional array in a dictionary

I am trying to store a multi dimensional array in VBA. I added the array to a key but I am not sure how I access it. I need to save an array of three for each key. The main array is a list of 15, 3 dimensional arrays.

Function test22()
  'Instanciate variables
  Set dict = New Scripting.Dictionary
  Dim hello As String
  hello = "Hello world"

  Dim test(0 To 15, 0 To 2) As String
  test(0, 0) = hello
  dict.add "key1", test

  'This line should print Hello World
  Debug.Print dict("key1").Value(0, 0)
End Function

Upvotes: 0

Views: 1089

Answers (1)

QHarr
QHarr

Reputation: 84465

You want

Debug.Print dict("key1")(0, 0)

dict("key1") will return an array. You then specify the location in that array directly as you would normally.

Upvotes: 1

Related Questions