VB6 question. Is there an easy way to copy member variables during object...

Thread Starter

kender

Joined Jan 17, 2007
264
VB6 question. Is there an easy way to copy member variables during object assignment instead of making a reference?


Colleagues,

I wasn’t able to find a definitive answer to this one on the web. Is there a way in VB6 to make a copy of an object without writing a copy function? What’s the best way to go about it?

Thanks,
- Nick

P.S. I’m writing my first VB6 classes. In C++ the default assignment operator copies the member variables to the new object. May be that’s what’s confusing me.
 

Mark44

Joined Nov 26, 2007
628
Nick,
To start off, I don't know the answer to your question, and I wasn't able to find out much about copy constructors and the like in the VB6 documentation on MSDN. Also, my expertise is more with C, C++, and C#, not VB.

Having said that, maybe you could find out by creating a couple of instances of one of your classes, and then assigning one to the other. If your class is relatively simple (with no members that are objects), it seems to me that the assignment operation should work. OTOH, if you have a more complicated class, you will probably need to come up with a copy operation so you don't wind up with multiple references to the same memory.
 
Top