"The code is exactly
how I would like to write code and the algorithms used are very
efficient and well-documented."
Van T. Dinh, Microsoft MVP
|
|
Class: CDictionary
This class demonstrates using the dictionary object Visual Basic 6 includes the Windows Scripting Host runtime component.
This dynamic link library adds the ability to create and use Dictionary objects, which are similar to VB Collections, but are more powerful and can also be used in VBA.
Unfortunately, several things are lacking in the dictionary object, and the documentation provide with VB 6 for this new object is thin at best.
This class accomplishes three things:
1. Works around the bugs in the version of the Windows Scripting Runtime that ships with VB 6
2. Provides detailed examples of how to use the dictionary object.
3. Provides additional functionality such as sorting the dictionary.
|
Procedure Name
|
Type
|
Description
|
|
(Declarations)
|
Declarations
|
Declarations and private variables for the CDictionary class
|
|
CompareMode
|
Property
|
Sets the the CompareMode property. This property is used by the Exists method to find keys in the dictionary.
Use Binary mode to do exact comparison. Use Text mode to case-insensitive comparisons.
|
|
Count
|
Property
|
Gets the count of objects in the dictionary
|
|
Dictionary
|
Property
|
Gets handle the current dictionary object. Use this object if you want direct access to the dictionary object.
|
|
Item
|
Property
|
Gets the item in the dictionary with the specified key.
|
|
Items
|
Property
|
Returns the Dictionary items as an array
|
|
Key
|
Property
|
Gets the key in the dictionary with the specified key
|
|
Keys
|
Property
|
Returns the Dictionary keys as an array
|
|
Add
|
Method
|
Adds the specified item to the Dictionary.
|
|
Class_Initialize
|
Initialize
|
Set initial values to defaults which may be overridden with property settings
|
|
DoSort
|
Private
|
Sorts the passed variant array
|
|
Exists
|
Method
|
Determines if the specified item exists in the dictionary. Comparison is done according to the setting of the CompareMode property.
|
|
Remove
|
Method
|
Removes the specified item from the Dictionary.
A runtime error occurs if the specified item does not exist.
|
|
RemoveAll
|
Method
|
Removes all items from the Dictionary
|
|
SortDictionary
|
Method
|
Sorts the Dictionary items.
This method copies all keys and items to arrays, sorts the array, removes all items from the dictionary, and then re-populates the dictionary with the contents of the sorted array.
|
Overview of Total Visual SourceBook
The source code in Total Visual
SourceBook includes modules and classes for Microsoft Access, Visual
Basic 6 (VB6), and Visual Basic for Applications (VBA) developers. Easily
add this professionally written, tested, and documented royalty-free code
into your applications to simplify your application development efforts.
Additional Resources
|
|