Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Visual Basic
Expertise: Beginner
Aug 26, 1999

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 Variant
Dim dict As Scripting.Dictionary

Set dict = New Scripting.Dictionary
dict.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 vItem
Next

Set 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).

Steve Griffs
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date