Objects are always passed by reference, not value. Why do you need to, the
code should control it?

Signature
---
HTH
Bob
(change the xxxx to gmail if mailing direct)
> Hi all,
>
[quoted text clipped - 37 lines]
> Thanks,
> Lyndon.
I don't think it can be done. How about declaring a new
instance of Test, e.g. Test1c and set its property values
equal to those of Test1? Do the latter with something
like this:
Sub CopyTestObj(x As Test, x2 As Test)
With x2
.Number = x.Number
End With
End Sub
Hth,
Merjet
At serious risk of being castigated by both Bob and Jim, you can pass
objects ByVal or ByRef. However in your example you are not changing the
reference to your class to a different instance of your class, merely
changing a property of the one and only class.
This might demonstrate.
Sub aaa()
Dim rA As Range, rB As Range
Set rA = Range("A1")
Set rB = Range("A2")
rA.Value = 1: rB.Value = 2
foo rA, rB
MsgBox rA.Address, , rA.Value
MsgBox rB.Address, , rB.Value
End Sub
Function foo(ByRef r1 As Range, ByVal r2 As Range)
Set r1 = Range("B1")
Set r2 = Range("B2")
r1.Value = 10: r2.Value = 20
End Function
Regards,
Peter T
> Hi all,
>
[quoted text clipped - 37 lines]
> Thanks,
> Lyndon.
Bob Phillips - 22 Jan 2007 20:31 GMT
Castigation coming <g>.
The object is not copied and passed to the called routine when passed as
ByVal, the reference to the object is passed by value instead of reference.
As you clearly demonstrate, even though the object itself is not changed, a
property of the object is changed, hence no copy.

Signature
---
HTH
Bob
(change the xxxx to gmail if mailing direct)
> At serious risk of being castigated by both Bob and Jim, you can pass
> objects ByVal or ByRef. However in your example you are not changing the
[quoted text clipped - 68 lines]
>> Thanks,
>> Lyndon.
Peter T - 22 Jan 2007 23:34 GMT
> Castigation coming <g>.
Was anticipating, and came back to leathered up and prepared !!
But we're all agreed so I can stand down <g>
Regards,
Peter T
> Castigation coming <g>.
>
[quoted text clipped - 83 lines]
> >> Thanks,
> >> Lyndon.