Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Art Art is offline
external usenet poster
 
Posts: 587
Default Scripting Dictionary in a class instance

Hi,

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")
mAvailableAccounts.RemoveAll
Set mReceivedAccounts = CreateObject("Scripting.Dictionary")
mReceivedAccounts.RemoveAll
Set mChildren = CreateObject("Scripting.Dictionary")
mChildren.RemoveAll

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 =
Dictionary(Key).

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.


  #2   Report Post  
Posted to microsoft.public.excel.programming
Art Art is offline
external usenet poster
 
Posts: 587
Default Scripting Dictionary in a class instance

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
retrieved.

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.


"Art" wrote:

Hi,

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")
mAvailableAccounts.RemoveAll
Set mReceivedAccounts = CreateObject("Scripting.Dictionary")
mReceivedAccounts.RemoveAll
Set mChildren = CreateObject("Scripting.Dictionary")
mChildren.RemoveAll

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 =
Dictionary(Key).

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.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Scripting Dictionary in a class instance

Art,
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.

NickHK

"Art" wrote in message
...
Hi,

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")
mAvailableAccounts.RemoveAll
Set mReceivedAccounts = CreateObject("Scripting.Dictionary")
mReceivedAccounts.RemoveAll
Set mChildren = CreateObject("Scripting.Dictionary")
mChildren.RemoveAll

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 =
Dictionary(Key).

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.




  #4   Report Post  
Posted to microsoft.public.excel.programming
Art Art is offline
external usenet poster
 
Posts: 587
Default Scripting Dictionary in a class instance

NickHK

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



"NickHK" wrote:

Art,
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.

NickHK

"Art" wrote in message
...
Hi,

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")
mAvailableAccounts.RemoveAll
Set mReceivedAccounts = CreateObject("Scripting.Dictionary")
mReceivedAccounts.RemoveAll
Set mChildren = CreateObject("Scripting.Dictionary")
mChildren.RemoveAll

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 =
Dictionary(Key).

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.





Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Unique Listbox Scripting Dictionary Jennifer Excel Programming 2 February 21st 07 02:08 PM
Collection VS Scripting.Dictionary Tetsuya Oguma Excel Programming 1 October 16th 06 09:49 AM
Scripting.Dictionary question Jennifer Excel Programming 6 October 12th 06 07:30 PM
Scripting.Dictionary Jennifer Excel Programming 2 October 12th 06 12:03 PM
VBA question - Set reference to run Scripting.Dictionary ajliaks[_12_] Excel Programming 2 April 17th 04 03:47 PM


All times are GMT +1. The time now is 03:26 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"