Düzenle

Aracılığıyla paylaş


Dictionary object

Object that stores data key/item pairs.

Syntax

Scripting.Dictionary

Remarks

A Dictionary object is the equivalent of a PERL associative array. Items, which can be any form of data, are stored in the array. Each item is associated with a unique key. The key is used to retrieve an individual item and is usually an integer or a string, but can be anything except an array.

The following code illustrates how to create a Dictionary object.

Dim d                   'Create a variable
Set d = CreateObject("Scripting.Dictionary")
d.Add "a", "Athens"     'Add some keys and items
d.Add "b", "Belgrade"
d.Add "c", "Cairo"
...

Methods

Method Description
Add Adds a new key/item pair to a Dictionary object.
Exists Returns a Boolean value that indicates whether a specified key exists in the Dictionary object.
Items Returns an array of all the items in a Dictionary object.
Keys Returns an array of all the keys in a Dictionary object.
Remove Removes one specified key/item pair from the Dictionary object.
RemoveAll Removes all the key/item pairs in the Dictionary object.

Properties

Property Description
CompareMode Sets or returns the comparison mode for comparing keys in a Dictionary object.
Count Returns the number of key/item pairs in a Dictionary object.
Item Sets or returns the value of an item in a Dictionary object.
Key Sets a new key value for an existing key value in a Dictionary object.

See also

Support and feedback

Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.