As far as I can tell, the Object Dictionary key is created simply by referencing it, as if it existed.
wscript.echo objDic.Item("test") 'Creates the key whether it exists or not wscript.echo objDic.Exists("test") 'Will now return true
Here is another code you can try to prove / test my theory. I usually use MsgBox instead of WScript.Echo, as you will see in my code.
dim objDic, brk brk = vbcrlf & vbcrlf set objDic = createobject("scripting.dictionary") objDic.add "test","I have not been deleted" wscript.echo "objDic.Exists(""test""): " & brk & objDic.item("test") WScript.Echo "Now going to Remove the key named: test" objDic.remove "test" MsgBox "objDic.Exists(""test""): " & brk & objDic.Exists("test") 'Returns False wscript.echo "objDic.item(""test""): " & brk & objDic.item("test") 'Shows Blank, Creates the key again with a blank value wscript.echo "objDic.item(""NeverAdded""): " & brk & objDic.item("NeverAdded") 'Also shows blank, does not return an error MsgBox "objDic.Exists(""test""): " & brk & objDic.Exists("test") 'Returns True
Hk1
source share