Sub test()
Dim authDict As Dictionary
Set authDict = CreateObject("Scripting.Dictionary")
authDict.Add "Anton", 1
authDict.Add "Martin", "3"
authDict.Add "Dave", 1
testKey = authDict.Exists("Alina") ' False, but adding this Key to dictionary by itself
testVal = authDict("Alina")
testKey2 = authDict.Exists("Alina") ' now it true
testVal2 = authDict("Alina")
End Sub
为什么在不存在状态字典的情况下,它们会自行添加此键到字典中?如何防止这种情况发生?
testVal = authDict("Alina")
,它会添加到字典中。 - Mikku