I’ve had a quick look and unfortunately, it looks like there are a few pieces of the puzzle missing so this cannot be done.
An Alternative method would be to use a singleton instance in all of the places you supply the class.
Step 1 - Change From Shared Methods To Class Methods
a) Rename the classes Folder & Third (TableFolder / TableThird?)
b) Create a module with public properties Folder & Third which have the correct types
c) During your app initialisation create the class instances and assign them to the Folder & Third properties
d) Switch the shared methods to normal class methods
At this point your code should function the same way as it did before.
Step 2 - Refactor
As long as your table classes have the same superclass or same interface you should be able to refactor the methods so that it accepts the superclass / interface and performs all of the common work.
I’ve been down this road. Yes, it’s possible. Clumsy, but possible. You can use GetTypeInfo to get an introspection object for a class (not an instance) and interrogate that object to find your shared methods.
HOWEVER I strongly recommend not doing this. I ended up refactoring away from this because of random inexplicable problems.
What I was finding is that some users would have no problem using the app, then all of the sudden these classes would act like they didn’t exist. After adding a bunch of logging, it turned out that introspection just couldn’t see the target methods. It’s as if their signatures changed inside a built and signed binary. Nothing would bring the missing methods back except a reinstall. And it would work for a while, then just… not. This only happened to certain users too. It was the strangest thing I’ve ever seen. So I changed how my code worked to not need introspection - which meant an annoying select statement - but the result is much more reliable.
So… don’t do it. I’ve been down that road. Just don’t do it. I know the alternative isn’t exactly elegant, but it works every time, and that is worth far more.
Thank you @Thom_McGrath for your feedback. Of course I like elegant code, my first goal is maintainable code but first of all I want robust code without random inexplicable problems.
You could have both classes implement a Class interface if you change the Shared to an instance method (you can still have a shared method or property that contains the actual value, but is returned from the instance method(s)):
Add a new Class Interface, name it TableNameProvider
Add a Function to The TableNameProvider named “TableName” set String a returnvalue
In your “Folder” and “Third” class implement the TableNameProvider interface (just below the super class in the inspector).
Now add the code in “Folder” and “Third” that returns the value.
In your CreateTable method your param could be TableName As TableNameProvider.