Polymorphism in VBA
Hey everyone,
Ive been given the daunting task on creating a macro in MS Excel. I know VBA is probably the least favorite and most unsuitable for this forum, but I would greatly appreciate your help.
The problem is that I want to implement interfaces, but for some reason the compile just doesn’t take it, and spits out an error saying the function in the interface is not implemented. Here’s my code:
clsInterface
Code:
public sub run()
end sub
clsDerived
Code:
Implements clsInterface
Public Sub Class_Initialize()
MsgBox "in derived"
End Sub
Public sub run()
MsgBox "Please work"
End sub
ThisWorkbook
Code:
Dim cls As clsInterface
Dim derived As clsDerived
Set cls = New clsInterface
Set derived = new clsDerived
Set cls = derived
Ive wrecked my brains on this for hours and have not figured out why i get the error. Again, the error is: "Object module needs to implement 'run' for interface clsInterface
Thanks a million
raven