Page 1 of 1

VB class copying

Posted: Thu Dec 23, 2004 10:42 am
by dh
(fixed the title)

Basically I have a "Class in a variable"(tm) and I'm working on a "flush" function to remove all unused slots (unused being thoes declared to be "set Program_Threads(i) = nothing".) and pile thoes used starting a zero. This frees up some memory for other things.

The problem is I can't seem to find a way to copy one to another. (some variables are read-only and such) directly.

Thanks ahead (I know some people are thinking: "what the hell is this guy doing without knowing how to do <such and such>!!". well , I'm working in unknown (to me) territory (eg. graphics + classes, etc.))

Re:VB class copying

Posted: Wed Jan 05, 2005 10:31 am
by dh
Anybody?

I'll try this: set x = new y
if you can't copy, please say so!!

Thanks

Re:VB class copying

Posted: Wed Jan 05, 2005 1:07 pm
by Candy
I think the reason for the amount of replies is that you ask about Visual Basic on a forum where half the visitors are OS developers (who mainly use system languages) and that the larger part of the other half are AGI/SGI developers, who are also a far way from Visual Basic.

Re:VB class copying

Posted: Thu Jan 06, 2005 4:12 pm
by dh
@candy: ok, understood.

@everyone else: i'm free to help in VB where others need it ;P

Thanks anyway

Re:VB class copying

Posted: Fri Jan 07, 2005 2:47 am
by distantvoices
maybe this is of help?

http://www.devx.com/vb2themax/Tip/19437

or you google for:

visual basic object cloning.

because If I understand you correctly, you want to have two instances of the same class filled with the same content in memory. this has to be done via *deep* copying, say, each and every thing in the memoryarea allocated for the object is copied over to the newly created object's memory area.

Like in c: If you want to copy the content of one array into another one, you canna simply say a=b, because this only moves the first position from b to the first slot of a and thats it. Here you need to memcpy the content of b to a in the size of b. (ie: amount of slots * size of array data type)

Hope this makes the things a bit clearer.

btw: don't expect too much help from me, I'm not very deep into visual basic. have just done a few apps with it, mainly web services and soap stuff.

Re:VB class copying

Posted: Fri Jan 07, 2005 10:45 am
by dh
@BI: any help is good!!! I'll look into it. (You hit my meaning right on the dot!)

thanks again