CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: Copying objects

  1. #1
    Join Date
    Dec 2000
    Location
    Canada
    Posts
    59

    Copying objects

    When I use

    set newobject = oldobject



    the newobject will change when the oldobject changing. How do I do this but just copy the object.

    Thank you




  2. #2
    Join Date
    May 2001
    Posts
    155

    Re: Copying objects

    What kind of object? picturebox,text,etc.

    --Ant
    ------------------------------------------------------------------------------------------------------------------------
    Want Free Software?
    E-mail me at: cgeorge@thevortex.com

  3. #3
    Join Date
    Dec 2000
    Location
    Canada
    Posts
    59

    Re: Copying objects

    the object is declared like this

    Dim newobject as Object

    Later is set like:
    set newObject = Mapobject2.valuemaprenderer




    Thank you for any help



  4. #4
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    Re: Copying objects

    you may use collections:
    'did not tested full, so do not know if this will help
    'to "just copy the object" you should use
    'set myobj= new oldobj
    'or
    'load theobject
    'but if you cannot use New or Load...

    dim mycoll as collection
    '....
    set mycoll = new collection
    mycoll.add yourOldobject,"obj1"
    mycoll.add youroldObjasSecondobj, "obj2"
    ....
    mycoll("obj1").move 100,100

    mycoll("obj2").move 2000,2000
    '....
    'when finished:
    set mycoll= nothing

    Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, Bruno Paris and all the other wonderful people who made and make Codeguru a great place. Come back soon, you Gurus.
    ...at present time, using mainly Net 4.0, Vs 2010



    Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
    all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

  5. #5
    Join Date
    Jan 2000
    Location
    Olen, Belgium
    Posts
    2,477

    Re: Copying objects

    The type of object doesn't matter anyway. When using the set command, you actually copie the refference to the object, which always points to the same object in memory.

    Tom Cannaerts
    slisse@planetinternet.be

    Programming today is a race between software engineers striving to build bigger and better idot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning -- Rich Cook
    Tom Cannaerts
    email: cakkie@cakkie.be.remove.this.bit
    www.tom.be (dutch site)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured