Am 18.05.2018 um 13:28 schrieb Desmond Walsh:
On Thursday, May 17, 2018 at 10:03:03 AM UTC-4, Ulrich Möller wrote:
Am 17.05.2018 um 15:01 schrieb Desmond Walsh:
I have a data structure consisting of an array of User Defined Types (UDF) - called Udta say. Each Udta contains 4 members that are also UDT's - called Udtb say. I wrote a function to return a pointer to a specific Udtb. But to my surprise, the pointer creates a new instance of Udtb although it inherits from the Udtb I was trying to point to.
I have confirmed this behaviour by monitoring the variables in Local Window. I also display the pointer values using VarPtr.
My question. Is it possible to get a pointer to a specific Udtb as I am trying to do. It seems to me that I want 2 pointers pointing at the same UDF. I would prefer to stay with UDT's and not use classes.
The code is vba in Excel 2010.
Here you will find some detailed information about vba pointers:
https://bytecomb.com/vba-internals-a...ters-in-depth/
https://communities.bentley.com/prod...roperty-values
Therefore i would prefer objects instead udts andÂ* and pass them by
reference.
Ulrich
Thank you for the links. I am now convinced that a UDT design cannot easily support what I was trying to do.
I converted my Utdb to a class. My GetPointer function returns a Variant which I change to a class pointer in the calling procedure. Everything now works as I intended.
I will post some sample code illustrating the UTD problem and the simple conversion to a class based solution
Another helpful link may be
https://www.vitoshacademy.com/vba-at...gh-end-in-vba/
The interesting thing is how to create a static class in vba
Ulrich