I'm using an interface to ensure some similar classes implements some mandatory methods (subs/functions).
Example:
C1 and C2 also need methods that are exactly the same, for example methods SM1 and SM2.
To avoid repeating SM1 and SM2 I'd like to define an abstract class AC:
which would be extended by C1 and C2
This solution is indeed possible in Java, but I don't find any documentation for doing the same in VBA. (VB.Net seems to allow abstract classes using keyword MustInherit.)
Any confirmation it is possible or not in VBA?
There is no inheritance in VBA.
You can define an interface and you can implement it in a class by using the Implements
keyword. But if you want shared functionality pre-implemented by a base class, you have to use the copy-paste approach.
Related reading:
How to use the Implements in Excel VBA
How to use comparison methods between class object modules in VBA in a similar manner as VB.NET?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With