Results 1 to 5 of 5

Thread: 2 Reference of one Instance

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2000
    Location
    Alps, Europa
    Posts
    7

    Wink

    How can i compare 2 refernces of One Instance of an Object

    Example:

    Set objA = CreateObject ("ClassString.Class")
    Set objB = ObjA

    If ObjB = ObjA Then MsgBox ("OK")

    etc...

    why does this compare of 2 Instances not work ???

    Is there a other way ??


    thanks
    Stonebrook

  2. #2
    Fanatic Member simonm's Avatar
    Join Date
    Sep 2000
    Location
    Devon, England
    Posts
    796

    Lightbulb Well

    If there is a property that generates a unique identifier everytime an instance is created then you can compare these.

    If not, it could be tricky. Change a property value on one and then see if it changes on the other?

  3. #3
    Guest

    pointers

    it doesnt work because you are asking if two pointers
    are the value..since A points to the data and B points to A they will not be the same...

    i know somebody will say VB doesnt use pointers...
    but it actually uses a vtable of addresses and thats
    pretty much the same thing..

    in "C" it's called indirect reference...

    since you are assigning these pointers to objects...

    A -> object
    B -> A

    this would work.. A.Property = cow
    B.Property = cow

    otherwise A = object address
    B = A address

    that was easy huh....

  4. #4

    Thread Starter
    New Member
    Join Date
    Oct 2000
    Location
    Alps, Europa
    Posts
    7

    ... next

    ... what happens with the Refernce of Object B if i free Object A ??

  5. #5
    Fanatic Member simonm's Avatar
    Join Date
    Sep 2000
    Location
    Devon, England
    Posts
    796

    Post Nothing.

    Because B is NOT pointing to A. B is pointing to the object. If you remove A, B will still be referencing the same object.

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