Dr.K
06-26-2008, 08:38 AM
Ok, I understand passing variables ByVal and ByRef, but does it really work the same way for passing Objects?
I've gotten errors by trying pass Objects either way, so now I don't declare either type when passing Objects. Actually, the whole thing is so confusing that when I need to pass Objects, I usually just make them module-level Private variables.
How would a ByVal Object even work?
-It just makes a completely seperate copy of the Object?
-Is the Object properly destroyed at the end of the procedure?
(or do I have to Set it equal to Nothing before the Sub ends)
-What about Object relationships? Do they come too?
Example: I pass an Outlook Mail Object to a sub, can I work my way back up the Object tree to the Outlook Application? Or is the copy some kind of wierd orphan Object?
I've gotten errors by trying pass Objects either way, so now I don't declare either type when passing Objects. Actually, the whole thing is so confusing that when I need to pass Objects, I usually just make them module-level Private variables.
How would a ByVal Object even work?
-It just makes a completely seperate copy of the Object?
-Is the Object properly destroyed at the end of the procedure?
(or do I have to Set it equal to Nothing before the Sub ends)
-What about Object relationships? Do they come too?
Example: I pass an Outlook Mail Object to a sub, can I work my way back up the Object tree to the Outlook Application? Or is the copy some kind of wierd orphan Object?