If I create a method and as a parameter I pass in a dictionary, are my local modifications to the passed in dictionary retained on the method’s exit, or do I need to pass the dictionary ByRef?
MyMethod(theDictionary As Dictionary, count As Integer)
MyMethod(ByRef theDictionary As Dictionary, count As Integer)
I’m not getting the results I’m expecting after locally modifying the dictionary contents using the intrinsic method and before I start making modifications to code, I want to make certain that I’m at least calling the method and passing the dictionary properly.
Okay, so I don’t know if it’s SUPPOSED to be different, but passing the dictionary ByRef instead of intrinsically has sorted the oddity that I was witnessing.
Works as expected here.
[code]Dim d As New Dictionary
d.Value(“MOO”) = “A”
System.DebugLog(Str(d.Count) + " " + d.Value(“WIBBLE”))[/code]
Public Sub MyMethod(theDictionary As Dictionary)
theDictionary.Value("WIBBLE") = "B"
My debug output is “2 B”
As dictionary is an object it should be passed ByRef as standard without having to specify it.
Well, something was happening and the only thing I changed was the parameter signature - New Mysteries … :S
when you pass byref, you can assign a new dictionary to the original variable in the calling method.
Stranger still. I exited 15r3, relaunched and reloaded the app - removed the ByRef call and now it’s working - Ghost in the Machine!