Features
Ask DevGuru
ASP Resources
Find the Bug
Knowledge Base
Links
Tips of the Week
Tutorials
Products
dgCalendar
dgCharge New!
dgChart New!
dgFileUpload
dgReport New!
dgSort
dgTree
Site
Authoring
Coming Soon
DevGuru Resume
Link to Us
Merchandise
Sponsorships
Testimonials
What's New
Technologies
ADO 2.6
ASP
CSS2
HTML
JavaScript
Jet SQL
Transact-SQL Syntax
VBScript
WML
WMLScript
WSH
XML DOM
All Methods
METHOD: Dictionary.Keys
Implemented in version 2.0
[arrayname = ]
object.
Keys
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.
The following code demonstrates this, using the
Dictionary
object's
Count
property to determine the amount of key/item pairs.
Code:
<%
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"
arrayItems = guitars.Keys
for i = 0 to guitars.Count -1
Response.Write "<br>Key = " & arrayItems(i) & "Item = " & _ guitars.Item(arrayKeys(i))
next
%>
Output:
"Key = e Item = Epiphone"
"Key = f Item = Fender"
"Key = g Item = Gibson"
"Key = h Item = Harmony"
Copyright 1999-2001 by Infinite Software Solutions, Inc. All rights reserved.
Trademark Information