Cloning an object

  • Thread starter Thread starter meh
  • Start date Start date
M

meh

ya know I thought that if I added a new Tabpage and then assigned it to an
existing tabpage that I would get a clone of the Tabpage......i.e.
Dim tp As New TabPage()

tp = TabPage1

Me.TabControl.TabPages.Add(tp)

But this is not giving me the results I expected. Is the TabPage not an
object in and of itself????


ne thoughts

tia
meh
 
Object variables are just handles/refrences to the actual object ( a blob of
memory representing the object's data ).
When you assign one reference to another, you don't clone the object, you
get two references that point at the same object.

-Rob Teixeira [MVP]
 
Thx Rob
I guess I was thinking in terms of child forms in a MDI app. i.e.
Dim child1 As New frmChild()

Which (i think) is a copy of all the forms objects........

I was trying to do a similar thing with the TabPage in that as I needed a
new TabPage I wanted to get a duplicate if the boilerplate tabpage.

I'm sorry if these questions are too elementary but I keep thinking I'm on
verge of getting this....:-)

Can someome point me in the right direction...

tia

meh
 
The line with the New statement was correct.
All i'm saying is that the following line where you set one reference equal
to the other, does not clone.

Keep at it. It'll make sense soon :-)

-Rob Teixeira [MVP]
 
Back
Top