I am experimenting with VBA's Interfaces, and I'm a bit annoyed. Most of what I've read on the topic suggests using Interfaces as a means to achieve polymorphism, which seems to work in some of my use cases. Unfortunately, I have run into an issue.
I created a class module to define my interface iCanvasObject
I then created a class cTable
that implements all methods in iCanvasObject
. So far so good, everything works as expected.
The issue occurs when I define a method specific to cTable
, and not part of iCanvasObject
. Even if its Public
I can't seem to access it from a variable dimensioned as iCanvasObject
, but instantiated as cTable
.
Dim tbl As iCanvasObject
Set tbl = New cTable
Its not visible in IntelliSense which I could live with, but when I try to simply call the method directly, VBA complains of a Method or data member not found
error. Even though this variable is definitely of type cTable
Is there a way for me to create methods specific to cTable
that I can call while still utilizing the polymorphism benefits of the interface? Said another way, if I dimension a variable as iCanvasObject
, am I strictly limited to whats defined in this interface?