VBA: How to store a reference to an Object type within the Object type

KingLarryXVII

New Member
Joined
Jan 11, 2013
Messages
11
So this is a bit of a corner case, but I was setting up an Object, cPerson, and wanted to reference their parent's objects, which are also cPerson type, so I could call (rough example):

Set person = New cPerson
Set mother = New cPerson
Set father = New cPerson
set person.Mother = mother
set person.Father = father

The problem is that when I set the properties "Mother" and "Father" within cPerson, I can't have them as type cPerson (stack overflow because each mother needs parents and so on to infinity)

Question: Are there any ways I can create a reference to the 'mother' and 'father' objects within 'person' but not of the type cPerson?

Let me know if the question isn't clear. Thank you in advance!
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
To clarify (for any other readers)
"Set" is used when you're setting up an object variable. Remember - objects are like Workbooks, Sheets, Shapes - the things that can have properties and methods assigned to them.
"Let" is used for normal variables, when you're assigning a value

"Get" is when you are retrieving the variable, one either created from Set or Let
 
Upvote 0

Forum statistics

Threads
1,215,129
Messages
6,123,210
Members
449,090
Latest member
bes000

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top