Version: 2.0
The Keys method is used to retreive all of the keys in a particular Dictionary object and store them in an array.
The Keys method can be used to retreive all the keys in a Dictionary object and place them in an array. We can then iterate through the keys using a For....Next loop.
<%
dim guitars, arrayKeys, i
set guitars=CreateObject("Scripting.Dictionary")
guitars.Add "e", "Epiphone"
guitars.Add "f", "Fender"
guitars.Add "g", "Gibson"
guitars.Add "h", "Harmony"
arrayKeys = guitars.Keys
for i = 0 to guitars.Count -1
Response.Write ("<br>Key =" arrayKeys(i)
"nbsp;Item = " _ guitars.Item(arrayKeys(i)))
next
%>
"Key = e Item = Epiphone"
"Key = f Item = Fender"
"Key = g Item = Gibson"
"Key = h Item = Harmony"
This code demonstrates using the Dictionary object's Count property to determine the amount of key/item pairs.