private sub changeNewPerson
'here is where I want to change the newperson value
end sub
My response might sound like attitude but its not.
My response is "So whats stopping you?"
private sub changeNewPerson
'here is where I want to change the newperson value
dim anotherperson as new person()
me.newperson = anotherperson
Because you passed newperson by ref the newperson in the code block
that instantiated this form and passed its person into the constructor
of this form, will now point to another person as well.
If you had of passed by val you could have done
Me.newperson.someproperty = xyz
and this would have affected the person in the calling class (because
they are "both" pointing to the same person.) Note i said "both".
BUT
you if you did this
me.newperson = anotherperson,
the person in the calling code would still point to the old person.
Thats because ByVal essentially creates another variable that gets put
on the stack so you have two variables on the stack pointing to the
same object on the heap.
So when you change the heap reference in one var you dont change it in
the other.
Passing By Ref, passes the orignal address on the stack, so when you
change the object thats it pointing to, this affects both the variable
in the calling code and that in this form. *Variables* are just memory
addresses. And in this case there is only "one".
Having said all of this. I would make changeperson a function and
explicitly return a reference to the calling code. It makes things
clearer and much more understandable for the next guy/girl developer.
I would also include a counselling method, because i suspect some of
these people are going to have start experiencing some serious
identity crisis'.
hth
Richard