I am using dictionaries in Excel VBA via dict As New Dictionary
(and adding a reference to the scripting runtime). When I try to monitor those during debugging, I can only see the keys which lie in the dictionary, but not the respective value of each key.
Is there any way to see the value as well? It would make debugging much more easy for me.
EDIT: Based on your answers, there is no easy solution, but I can do the following.
Use a global variable Dim d_obj As Object
and monitor it constantly and whenever I need to look up a value of a dictionary, I type into the immediate window Set d_obj(key) = ...
and I will be able to see the value in the monitor-window.
What I may do in addition is write a function which takes in a dictionary and returns the values as a list and use this function similarly at the direct window. Thx to all!
?dict.Item(1)
– Luminarydict(yourKey)
in the watch window. Note that there is a bug in some versions of VBA: if you typedict(aKeyThatDoesNotExist)
in the watch window, that key might get created with a null value which causes weird and difficult to reproduce bugs... – MilkliveredDim dict as Dictionary
toDim dict as MyDictionary
. The rest would be unchanged. But that's a lot of work just for debugging... – Milklivered?dict.Item(1)
method will not work. Regarding defining a separate class, I have thought about that, but in my case dismissed it for not worth it. @lori_m: I would certainly use such a utility if it existed. – Longish