Changing array values in a VBA dictionary
Posted
by Pawan Jain
on Stack Overflow
See other posts from Stack Overflow
or by Pawan Jain
Published on 2010-03-08T19:47:23Z
Indexed on
2010/03/08
19:51 UTC
Read the original article
Hit count: 525
Hi
I have a piece of code that does not seem to do what it is expected to do. VBA Arrays are mutable by all means, but it seems that when they are stored into a Dictionary as values of some keys, they are not mutable anymore. Any ideas?
Sub foo()
Dim mydict As New Dictionary
mydict.Add "A", Array(1, 2, 3)
MsgBox mydict("A")(1)
' The above shows 2, which is fine
mydict("A")(1) = 34
MsgBox mydict("A")(1)
' The above also shows 2, which is not fine
End Sub
© Stack Overflow or respective owner