Determining the Number of Key-Item Pairs in a Dictionary

Microsoft® Windows® 2000 Scripting Guide

microsoft windows 2000 scripting guide

« Previous | Next »   

Like most collections, the Dictionary object has a Count property that returns the number of key-item pairs in the collection. The script in Listing 4.46 creates an instance of the Dictionary object, adds three key-item pairs, and then echoes the value of the Count property.

Listing 4.46   Determining the Number of Key-Item Pairs in a Dictionary

1 2 3 4 5 
Set objDictionary = CreateObject("Scripting.Dictionary") objDictionary.Add "Printer 1", "Printing" objDictionary.Add "Printer 2", "Offline" objDictionary.Add "Printer 3", "Printing" Wscript.Echo objDictionary.Count

When this script runs, the value 3 (the number of key-item pairs in the collection) will be echoed to the screen.


send us your feedback Send us your feedback « Previous | Next »   


Microsoft Windows 2000 Scripting Guide(c) Automating System Administration 2003
Microsoft Windows 2000 Scripting Guide(c) Automating System Administration 2003
ISBN: N/A
EAN: N/A
Year: 2004
Pages: 635

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net