C
Chris
Hi
I have a number of arrays of classes with which i want to copy to data from
one element to another, but when i do the data in the first class remains
referenced to the data in the second.
Perhaps i can make more sense with this:
Class MyClass1
dim a as byte
dim b as byte
end class
sub main
dim a(50) as myclass1
dim f as integer
' fill it with stuff
for f=0 to 50
a(f).a=rnd(255)
a(f).b=rnd(255)
next
' ok here is where the problem is
dim t as myclass1
t=a(25)
' if i look at a(25).a it could be say 30 and t.a is also 30
t.a =50
' at this point t.a should be 50 and a.(25).a should remain at 30
' but im finding in my program that a.(25).a is changing to 50 as well,
' it is like the t=a(25) is only setting a pointer to the reference in the
'a' array
' and not copying the data from a(25) to t making t a separate instance.
end sub
If this is supposed to happen haw do i get the data out of the required
element of
the array and put it into a var and lose its reference.
I have a number of arrays of classes with which i want to copy to data from
one element to another, but when i do the data in the first class remains
referenced to the data in the second.
Perhaps i can make more sense with this:
Class MyClass1
dim a as byte
dim b as byte
end class
sub main
dim a(50) as myclass1
dim f as integer
' fill it with stuff
for f=0 to 50
a(f).a=rnd(255)
a(f).b=rnd(255)
next
' ok here is where the problem is
dim t as myclass1
t=a(25)
' if i look at a(25).a it could be say 30 and t.a is also 30
t.a =50
' at this point t.a should be 50 and a.(25).a should remain at 30
' but im finding in my program that a.(25).a is changing to 50 as well,
' it is like the t=a(25) is only setting a pointer to the reference in the
'a' array
' and not copying the data from a(25) to t making t a separate instance.
end sub
If this is supposed to happen haw do i get the data out of the required
element of
the array and put it into a var and lose its reference.