Scripting Dictionary in a class instance

Scripting Dictionary in a class instance

Post by QXJ0 » Thu, 29 Mar 2007 08:22:20


I'm having a weird problem -- maybe it's me. I've set up a class. Each
instance will be stored in a scripting dictionary. Each instance will also
contain 3 other scirpting dictionaries for various purposes.

The class is called Parent

In the Initialize statement I have:
Set mAvailableAccounts = CreateObject("Scripting.Dictionary")
Set mReceivedAccounts = CreateObject("Scripting.Dictionary")
Set mChildren = CreateObject("Scripting.Dictionary")

In the main routine I create a new Parent. Put in the fields needed to
create a key. Check the dictionary that stores these Parents, looking for
the key. If I find one, I set Parent=nothing, and then set Parent =

When I do this, it appears that the 3 dictionaries within that "retrieved"
instance are being reset to contain no elements.

Am I doing something wrong -- that you can tell from the info I've listed?
Are scripting dictionaries within classes somehow static and not specific to
an instance?

Any help would be appreciated.

Scripting Dictionary in a class instance

Post by QXJ0 » Thu, 29 Mar 2007 09:09:52

OOPS! Never mind -- I'm stupid.

What I was doing, and I didn't put enough in my post to let anyone see it was:

I had some of the code in a "with block", specifically "with Parent". When
I recalled an old Parent from the scripting dictionary, I was still in the
with block. So the "dotted" fields still referred to the previous Parent,
not the one I just

I can't believe how long it took me to find that! I appreciate the time any
of you took in reading through my, unfortunately incomplete, question.


Scripting Dictionary in a class instance

Post by NickH » Thu, 29 Mar 2007 13:12:17

Whilst your code seems to be working, it may not be a good idea to use
"Parent" as the class name, as that exists already. Maybe "cParent" to avoid
confusion for you, other developers and the compiler.



Scripting Dictionary in a class instance

Post by QXJ0 » Thu, 29 Mar 2007 21:20:06


Thanks for the advice -- that seems like a good practice.