Post

 Resources 

Console


That isn't the same... Rag on a Stick (0 replies, 1 views) (2001-Mar-16)
-
That would only copy the values rather than make one point to the other. The difference? Dim cMyClass As SomeClass Dim cMyClass2 As SomeClass Set cMyClass = New SomeClass Set cMyClass2 = cMyClass cMyClass.Value = 5 Debug.Print MyClass2.Value ... That will output 5. With UDTs: Dim udtMyUDT As SomeUDT Dim udtMyUDT2 As SomeUDT udtMyUDT2 = udtMyUDT myUDT.Value = 5 Debug.Print udtMyUDT2.Value That will output 0. Why? With a Class, the variable you Dim is actually an object reference, this means it is pretty much the same as a pointer: it stores the memory address of the class, but not the information about the class. (That is why it is only 8 bytes, when the class itself can take up way more than that). When you do Set Blah = Blah, you are setting the pointers, not the values. With a UDT, the variable you Dim IS the information, so its size depends on what elements you have. This means that they are always unique and can't be linked the same way. As for answering the question, the way to do it, would be to have only one UDT. Its hard to explain, but if you have an array of UDTs, you can do stuff similar to pointers (by using the index of the array as a memory address). That works quite well.


-
Up One Level | Back to Forum


Copyright © 2002 - 2004 Eric Coleman, Peter Kuchnio , et. al.
There have been 21 visitors within the last 20 minutes
RSS News Feed