Iterating Over Dictionary Items

What’s the best way to loop through (iterate over) all the items (key-value pairs) in a dictionary? Can a “for” loop of some kind be used? Can anyone point me to some sample code?

Thanks much,

-Steve

dictionary.keys() returns an array of variants. something like this (from memory):

[code]dim keys(), k, v as variant
dim i as integer

keys = myDictionary.keys()
for each k in keys
v = myDictionary.value(k)
// do something with v
next[/code]

Aha! Thanks, Brad! I was hoping it might be as simple as…

for each key : val in myDictionary // use key and/or val next

I guess that’s what my PHP experience was suggesting.

BTW, is there an advantage to assigning the keys array to a local variable? I mean, why not just…

for each k in myDictionary.keys()

-Steve

You can also get d.Values for an array of all the values.