Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

objects not behaving as distinct 1

Status
Not open for further replies.

ChrisParks

Technical User
Feb 27, 2007
10
US
all

i am declaring two objects with diff names, lets say obj1 and obj2 equal to new ObjectTest objects

i first define all the characteristics of obj1 based on objecttest class characteristics

then i want to set obj2 = obj1 but subsequently manipulate the characteristics of obj2

when i do this, for example
set obj2.NumberValue = obj1.NumberValue - 1

assuming obj1.NumberValue = 20

it will then set obj2.NumberValue = 19. but it ALSO changes Obj1.NumberValue = 19 as well which i do not want. i want to maintaing obj1.numbervalue at 20

this makes no sense to me. why is it happening? and how can i avoid this?

thanks very much

-jared
 
set obj2 = obj1
So, you have only one instance of the ObjectTest object with 2 different names ...

To avoid this you have to instantiate obj1 and obj2 with the New keyword each.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
i have set obj1 and obj2 both equal to objecttest which is a class

so obj1 and ob2 should represent objects of class objecttest

so i do not think this solution applies? maybe i am missing somethin here
 
Why not posting your actual code ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
nothig much to it....

a class exists, Sec_MBS with a property, SecCounter

Public ThisMBS As new Sec_MBS
Public TempMBS As New Sec_MBS

ThisMBS.SecCounter = 20

Set TempMBS = ThisMBS

at this point tempmbs properties take on all the values of thismbs properties

tempmbs.seccounter is currently 20

tempmbs.seccounter = thismbs.seccounter - 1


here, both tempmbs.seccounter and thismbs.seccounter become 19

i want thismbs.seccounter to maintain its original value of 20

makes no sense to me

hope this helps you help me

thanks
 
Set TempMBS = ThisMBS
At this stage the previous instance of the Sec_MBS object referenced by TempMBS is destroyed and TempMBS now references the same instance as ThisMBS.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
how can i set one objects values equal to another without destroying the original?
 
Have you tried this ?
Set TempMBS = New ThisMBS

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top