On Line 42 where it says
"WScript.Echo "The count after using the second for ... next loop Is " & objDictionary.Count"
objDictionary.count gets incremented by 1. Does anyone know why this is happening?
Option Explicit
Dim objDictionary, i
Dim arrKeys, Key
Set objDictionary = CreateObject("scripting.dictionary")
objDictionary.add 1, "server1"
objDictionary.Add 2, "server2"
objDictionary.Add 3, "server3"
objDictionary.Add 4, "server4"
arrKeys = objDictionary.keys
wscript.echo "arrKeys is " & vartype(arrKeys)
For Each Key in arrKeys
wscript.echo "key " & key & " is a " & vartype(key)
Next
For i = 1 To objDictionary.count
WScript.Echo objDictionary.item (i)
Next
objDictionary.Add "5", "Server5"
WScript.Echo "The count after adding key ""5"" with ""server5""" & _
" to the dictionary is " & objDictionary.Count
For i = 1 To objDictionary.count
WScript.Echo objDictionary.item (i)
Next
WScript.Echo "The count after using the second for " _&
"... next loop Is " & objDictionary.Count
WScript.Echo "Key ""5"" is a " & typename(objdictionary.item("5"))
WScript.Echo "Key 6 is a " & typename(objdictionary.item(6))
"WScript.Echo "The count after using the second for ... next loop Is " & objDictionary.Count"
objDictionary.count gets incremented by 1. Does anyone know why this is happening?
Option Explicit
Dim objDictionary, i
Dim arrKeys, Key
Set objDictionary = CreateObject("scripting.dictionary")
objDictionary.add 1, "server1"
objDictionary.Add 2, "server2"
objDictionary.Add 3, "server3"
objDictionary.Add 4, "server4"
arrKeys = objDictionary.keys
wscript.echo "arrKeys is " & vartype(arrKeys)
For Each Key in arrKeys
wscript.echo "key " & key & " is a " & vartype(key)
Next
For i = 1 To objDictionary.count
WScript.Echo objDictionary.item (i)
Next
objDictionary.Add "5", "Server5"
WScript.Echo "The count after adding key ""5"" with ""server5""" & _
" to the dictionary is " & objDictionary.Count
For i = 1 To objDictionary.count
WScript.Echo objDictionary.item (i)
Next
WScript.Echo "The count after using the second for " _&
"... next loop Is " & objDictionary.Count
WScript.Echo "Key ""5"" is a " & typename(objdictionary.item("5"))
WScript.Echo "Key 6 is a " & typename(objdictionary.item(6))