devxlogo

Enumerate a Dictionary Object

Enumerate a Dictionary Object

Although the Dictionary object does not have an enumerator, it does have an Items method that returns a Variant array. You can use the For…Each construct on the array:

 Dim vItem As VariantDim dict As Scripting.DictionarySet dict = New Scripting.Dictionarydict.Add "Item1", "Item data 1"dict.Add "Item2", "Item data 2"dict.Add "Item3", "Item data 3"For Each vItem In dict.Items	Debug.Print vItemNextSet dict = Nothing

Before you can use the Dictionary object in your application, you must set a Project Reference to the Microsoft Scripting Runtime (scrrun.dll).

See also  How IoT Tech Will Transform Logistics
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist