|Dictionary Object (VB6)|
- Microsoft Scripting Runtime (../ SYSTEM32/SCRRUN.DLL)
The Dictionary object is another new feature of VB6 that has found its way into wider use from its humble beginnings in Version 2 of the VBScript scripting runtime. The Dictionary object is similar to a Collection object, except that it's loosely based on the Perl associative array. Like an array or a Collection object, the Dictionary object holds elements, which are called items or members, containing data. A Dictionary object can contain any data whatsoever, including objects and other Dictionary objects. You access the value of these dictionary items by using unique keys (or named values) that are stored along with the data, rather than by using an item's ordinal position, as you do with an array. This makes the Dictionary object ideal when you need to access data that is associated with a particular unique named value.
So if you're happily using Collection objects throughout your VB programs, why should you want to change? Here are some of the advantages afforded by the Dictionary object over a Collection object:
A Dictionary object returns an array of all its keys using one simple method.
A Dictionary object returns an array of all its members using one simple method.
A Dictionary object lets you determine if a given key exists in the Dictionary.
A Dictionary object gives you the ability to overwrite a member value.
A Dictionary object lets you change a key value.
If that's not ...