Results 1 to 6 of 6

Thread: Excel VBA: Dictionary: Can I: Delete 'used entries' while iterating thru Keys RESOLVE

Threaded View

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    May 2004
    Location
    Carlisle, PA
    Posts
    1,045

    Resolved Excel VBA: Dictionary: Can I: Delete 'used entries' while iterating thru Keys RESOLVE

    Esteemed Forum Participants and Lurkers:
    ===============================
    Excel 2003 VBA

    I am doing some relatively low level 'artificial intelligence', and I think the easiest way achieve my objective is to make a pair of dictionaries, and to iterate through 1 of the dictionaries checking for matching entries in the second dictionary. What I need to do in the case of a match, is to REMOVE both of the dictionary entries.

    The question is: "is it safe to REMOVE dictionary entries WHILE ITERATING through the dictionary ???"

    If this is UNwise, I need to rethink my whole approach.

    Here is a code snippet:
    Code:
        For Each aKey In PROGd.keys
            'Check for a matching key in the DISTRO Dictionary
            If DISTd.exists(aKey) Then
                'We are DONE with these keys, so delete them!
                PROGd(aKey).Remove
                DISTd(aKey).Remove
            End If
        Next aKey
    It is actually a whole lot more complex than this code, but what I am doing is looking for exceptions where 2 lists do NOT match. When I get done iterating through 1 dictionary, the remainders in both dictionaries are all of the exceptions that I need to harpoon.

    Thank you for any and all comments, suggestions, and assistance.
    Last edited by Webtest; Jul 11th, 2007 at 12:37 PM.
    Blessings in abundance,
    All the Best,
    & ENJOY!

    Art . . . . Carlisle, PA . . USA

Posting Permissions

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



Click Here to Expand Forum to Full Width