I am trying to mimic std::map<string, std::list<string> > in VBA (this case is very specific, but really any collection inside a nstd::map<>-like container)
I have found that the equivalent of std::map would be a Dictionary, but how about the last part?
Somehow the most I've found on the internet is that it is possible to add an array element like this to a Dictionary, though without any insight as to how to add elements AFTER this has been done:
Dim my_dictionary as Dictionary
Set my_dictionary = New Dictionary
my_dictionary.Add "KEY#1", Array("A", "B", "C")
'How would I add "D" here ?!
Sub Tester()
Dim d As Scripting.Dictionary
Dim arr, ub
Set d = New Scripting.Dictionary
d.Add "key1", Array("A", "B", "C")
Debug.Print Join(d("key1"))
arr = d("key1")
ub = UBound(arr) + 1
ReDim Preserve arr(0 To ub)
arr(ub) = "D"
d("key1") = arr
Debug.Print Join(d("key1"))
End Sub
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With