Copying objects

Results 1 to 5 of 5

Thread: Copying objects

  1. #1
    Mark Guest

    Default Copying objects

    I need to make a copy of an object, how do I do it? I am filling an object collection with objects. The problem is that after I set the object collection item equal to my object, if I then modify my object it modifies the object in the collection too. Basically instead of creating a copy, I am only creating a relationship between two objects. How do I get around this? I need to be able to modify my object without changing the object I already put in the collection.

  2. #2
    jason Guest

    Default RE: Copying objects

    if its within a function you can use byRef e.g.<BR><BR>function copyobj(byref objName)<BR><BR>newObj = objName<BR><BR>end function<BR><BR>i think that&#039ll work, but don&#039t take it as gospel, try it out instead. the MS VBscript language reference provides solid info on this<BR><BR>jason<BR><BR>

  3. #3
    Mark Guest

    Default Didn't work

    Didn&#039t work, it had the same effect as Set. Thanks though.

  4. #4
    jason Guest

    Default RE: Didn't work - in that case

    try craeting a new object, then writing a function to set it&#039s properties to the same as the previous object<BR><BR>function copyobject()<BR><BR>newObj.prop1 = myObj.prop1<BR>.....<BR><BR>end function<BR><BR>then you&#039ll be able to make mods to each, and be sure of the result being independent (hopefully)<BR><BR>jason

  5. #5
    Join Date
    Dec 1969

    Default RE: Copying objects

    If the objects in question support the .clone() method (ADO springs to mind) then use that...<BR><BR>Dunc

Posting Permissions

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