I have recently found out about VBIDE library, but I don't quite grap all of it's capabilities yet. I want to make a method that will instantiate correct Class based on classes found in my Project. Classes that fit as candidates to be instantiated Implement
InterfaceA
, and the exact class that I want to instantiate has property MType
and it returns Enumerated Value
Correct
.
So to sumarize how do I iterate over classes defined in my project in order to find Class that returns Correct
for Property MType
, and Instantiate that Class.
Thus far I know that I can Iterate over my modules with following code:
Dim Part As VBComponent
For Each Part In Application.VBE.ActiveVBProject.VBComponents
Debug.Print Part.Name
Next Part
What I am missing now how do I iterate over methods/properties of each class to find out what these mehods return?
Here is method I need to find, it varies from class to class by value it returns:
Public Property Get InterfaceA_MType() As Model_Types
IModel_MType = Severity
End Property
So as you can see this Property is pretty simple I am to assume that it will return same value all the time.
UPDATE: Per Dough Gancy's observation part of the answer is located in here
I can use ProcBodyLine(InterfaceA_MType)
and ProcCountLines(InterfaceA_MType)
to iterate over the procedure lines, match those lines witch one that has IModel_MType = Correct
.
This leaves out only instantiating the Class based on the Code Module. how do I do that?