我发现这里的主题回答了一半的问题: Scripting.Dictionary 的 RemoveAll() 方法是否首先释放其所有元素?
在我的例子中,值是 Dictionary 的实例,所以我有 Dictionary 对象的嵌套层次结构。
我的问题是我是否需要在每个子词典上调用 RemoveAll ?
' just for illustration
Dim d As Dictionary
Set d = New Dictionary
Set d("a") = New Dictionary
Set d("b") = New Dictionary
' Are the next section of code necessary?
' -------------------- section start
Dim key As Variant
For Each key In d
d.Item(key).RemoveAll
Next
' -------------------- section end
d.RemoveAll
Set d = Nothing