A
Andy Read
Dear all,
I thought I understood passing parameters ByVal and ByRef but I
clearly don't! If I define a simple class
of:
Public Class Person
Public Name as String
Public Age as Integer
End Class
Then pass a person object to a method 'ByVal'
Public Sub ChangePerson(ByVal Person as Person)
Person.Name = "MyName"
Person.Age = 22
End Sub
Why are the values Name and Age changed when I'm passing by value? I would
expect this behaviour when I'm passing by reference. I'm confused...(It's
not difficult!)
Any pointers to set me straight would be appreciated!
Thanks
I thought I understood passing parameters ByVal and ByRef but I
clearly don't! If I define a simple class
of:
Public Class Person
Public Name as String
Public Age as Integer
End Class
Then pass a person object to a method 'ByVal'
Public Sub ChangePerson(ByVal Person as Person)
Person.Name = "MyName"
Person.Age = 22
End Sub
Why are the values Name and Age changed when I'm passing by value? I would
expect this behaviour when I'm passing by reference. I'm confused...(It's
not difficult!)
Any pointers to set me straight would be appreciated!
Thanks