Quote Originally Posted by robertx
The challenge was to pass a reference type to a procedure, modify it and return the original value to the calling procedure.

I assume that when you pass a reference type to a procedure ByVal and reinitialise it that the passed copy of a pointer to the object is now pointing to a new object of the same type rather than the object to which it was pointing when it was passed. Therefore, the object can be modified whilst the original object remains intact.
You start off with one variable and one object. Let's call them var1 and obj1, so var1 contains the memory address of obj1. You call a method with an argument declared ByVal. The system creates a copy of var1 and that becomes that parameter in the method. You've now got var1 and var2, both containing the memory address of obj1. If you now create a new object and assign it to the parameter you've got var1 containing the memory address of obj1 and var2 containing the memory address of obj2. Any property value changes you make in the method are done through var2, so they affect obj2. Once the method completes control is returned to the calling method where var1 still refers to obj1. No changes were made in the method to obj1.

Now lets say that you call a method with an argument declared ByRef. The system creates a reference to var1 rather than a copy of it. You now have var2, which contains a reference to var1, which contains a reference to obj1. If you now create a new object and assign it to the parameter you are assigning obj2 to var2. var2 is a reference to var1, so obj2 gets assigned to var1. var1, which is the original variable, now refers to obj2, a different object to what it referred to before.