Results 1 to 9 of 9
  1. #1
    Platinum Lounger
    Join Date
    Nov 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    5,016
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Scripting Dictionary - Enumerate Keys (VB Scripting Runtime)

    I'm trying to find out how/ if this can be done. It's easy enough for the item values - just a For Each ... Next construct. But getting hold of the Key values has me tossed.

    Alan

  2. #2
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts

    Re: Scripting Dictionary - Enumerate Keys (VB Scripting Runtime)

    The Keys property returns an array of the keys which you can iterate with a loop.
    Regards,
    Rory

    Microsoft MVP - Excel

  3. #3
    Platinum Lounger
    Join Date
    Nov 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    5,016
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Scripting Dictionary - Enumerate Keys (VB Scripting Runtime)

    Beautiful! Thanks Rory - works as advertised.

    Alan

  4. #4
    5 Star Lounger st3333ve's Avatar
    Join Date
    May 2003
    Location
    Los Angeles, California, USA
    Posts
    705
    Thanks
    0
    Thanked 2 Times in 2 Posts

    Re: Scripting Dictionary - Enumerate Keys (VB Scripting Runtime)

    Actually, if you simply iterate through a Dictionary using a For Each loop (i.e. For Each varX in dctX ...), it's the Keys (rather than the Items) that you're iterating through. It's iterating through the Items that takes a little extra code.

  5. #5
    Platinum Lounger
    Join Date
    Nov 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    5,016
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Scripting Dictionary - Enumerate Keys (VB Scripting Runtime)

    Thanks. I haven't used the dictionary object much before and it might not be that suitable anyway. I'll have a play and see.

    Alan

  6. #6
    5 Star Lounger st3333ve's Avatar
    Join Date
    May 2003
    Location
    Los Angeles, California, USA
    Posts
    705
    Thanks
    0
    Thanked 2 Times in 2 Posts

    Re: Scripting Dictionary - Enumerate Keys (VB Scripting Runtime)

    In case it's useful to you, <!post=here,446,450>here<!/post> is a somewhat geeky intro-to-Dictionaries post I did a few years back.

  7. #7
    Platinum Lounger
    Join Date
    Nov 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    5,016
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Scripting Dictionary - Enumerate Keys (VB Scripting Runtime)

    Thanks again. As I said in my (apparently deja vu <img src=/S/grin.gif border=0 alt=grin width=15 height=15>) reply to that post, it seems to be an excellent rundown. It's also obviously a long time since I visited Dictionaries, so I'll have a ponder over the possibilities... and had I made my Lounge search less specific I'd have doubtless run across that thread. <img src=/S/bash.gif border=0 alt=bash width=35 height=39>

    Alan

  8. #8
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Scripting Dictionary - Enumerate Keys (VB Scri

    >intro-to-Dictionaries post I did a few years back.
    Steve, might you consider updating that post to indicate that Dictionaries are an ideal way to pass parameters to macros when communicating between applications. Your thread back then saved my bacon ....

  9. #9
    5 Star Lounger st3333ve's Avatar
    Join Date
    May 2003
    Location
    Los Angeles, California, USA
    Posts
    705
    Thanks
    0
    Thanked 2 Times in 2 Posts

    Re: Scripting Dictionary - Enumerate Keys (VB Scri

    That post is no longer editable (time expired), but if you post a reply to it in that older thread, that should do the trick.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •