ironfelix717
Registered User.
- Local time
- Today, 09:59
- Joined
- Sep 20, 2019
- Messages
- 193
Greetings,
Can someone help a dummy with improving/understanding OOP in VBA...
I have a main class that has some properties, which are "inherited' by it's child classes....
Here is a sudo-description of the structure:
Main Object ParentClass
Child object Child1
Child object Child2
I want to be able to use this object as such....
I hope that is helpful in explaining what I am looking for. Essentially "nested" classes with a single point of entry.
I know there are other ways of achieving something similar. Like using a 'SetParent()' method inside the children to grab the parent's properties, but this is kind of the inverse of what I am requesting.
Noob question! Sorry!
-Regards
Can someone help a dummy with improving/understanding OOP in VBA...
I have a main class that has some properties, which are "inherited' by it's child classes....
Here is a sudo-description of the structure:
Main Object ParentClass
Code:
Property Let/Get ID
Property Let/Get SystemType
Property Get MyChild1 as Child1
Set MyChild1 = new Child1
end property
Property Get MyChild2 as Child2
Set MyChild2 = new Child2
end property
Child object Child1
Code:
Sub DoSomething()
[*NEED TO USE ParentClass properties!*]
Example: Debug.print ParentClass.ID
Child object Child2
Code:
Sub DoSomething()
[*NEED TO USE ParentClass properties!*]
Example: Debug.print ParentClass.ID
I want to be able to use this object as such....
Code:
Sub Test()
dim ObjParent as new ParentClass
ObjParent.ID = "1000"
ObjParent.SystemType = 1
ObjParent.MyChild1.DoSomething()
'PRINTS THE ID "1000"
ObjParent.MyChild2.DoSomething()
'PRINTS THE ID "1000"
End Sub
I hope that is helpful in explaining what I am looking for. Essentially "nested" classes with a single point of entry.
I know there are other ways of achieving something similar. Like using a 'SetParent()' method inside the children to grab the parent's properties, but this is kind of the inverse of what I am requesting.
Noob question! Sorry!
-Regards