This code was working for several days, looping through a dictionary just fine. The loop started breaking, and I have extra keys in the dictionary and I have no idea where they came from.
I am creating a scripting.dictionary with the following:
Dim riskDict As New Scripting.Dictionary
After which, the object is empty, as seen in the watch:
I then add my first key/item pair:
riskDict.Add "Weight", Array("WP", 0)
And after running this one line of code, I now have this:
Where did these two extra keys (Item 2 and 3) come from?! This is a problem, since later in my code I use:
For Each key In riskDict
temp = riskDict(key)
...
Next key
And this loop breaks, since it starts referring to keys which are empty. This does not seem to have been happening until just now, and the code has been running fine for a few days. (I changed some things elsewhere in the code, but completely unrelated to this.)
Let me know if I am doing anything ridiculous, or missing something obvious, and thanks!