Results 1 to 3 of 3

Thread: Wierd (Scope?) Class problem

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2002
    Location
    Calgary, Alberta Canada
    Posts
    2

    Red face Wierd (Scope?) Class problem

    Okay, I have a really interesting problem that I can't figure out!

    I have a public class defined as CObjects, a globally accessable array Objs() (variable upper bound) and a function:

    (Assume that Objs(1) holds something)
    public sub OSet()

    dim O as new Cobjects
    dim O2 as new cobjects

    o = Objs(1)
    O2 = objs(1)

    O.AProperty = 5


    end sub

    Now the problem:

    Changing the variable O ALSO changes the Variable O2 AND the entry in the Objs() array.

    As you can see the only interaction between variables is when O and O2 are being set to Objs(1).

    I can't continue much further without this being answered, please help
    We've been dead for 28 years!

  2. #2
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    That is because you are actually only assigning a reference to the same object. You'd have to Clone the class or make it serializable in order to copy all the values over.

  3. #3

    Thread Starter
    New Member
    Join Date
    Jul 2002
    Location
    Calgary, Alberta Canada
    Posts
    2

    Cool Serialization

    Okay, I have tried

    <serializable()>Public class CObject
    ...
    ...
    ...
    end class

    still with the same result. Am I doing something wrong?
    (currently testing the clone theory)
    We've been dead for 28 years!

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