VBA - Is VBA An OOP Language, and Does It Support Polymorphism - Stack Overflow
VBA - Is VBA An OOP Language, and Does It Support Polymorphism - Stack Overflow
x Dismiss
Sign up
I would like to improve an existing VBA project used by a Microsoft Excel workbook by implementing classes and polymorphism.
My problem is:
1 - I read a lot of articles/forums which explain that VBA is not an Object Oriented Programming (OOP) language and do not support
Polymorphism.
2 - I also found some webpages like this one which explain how to perform OOP and polymorphism in VBA using keywords like Inherits,
Overrides, Overridable, MustOverrides.
So my question is :
3 Point 2 is about VB, not VBA. There is no such keywords like Inherits , Overrides , Overridable ,
MustOverrides in VBA. – mielk Aug 6 '15 at 14:22
5 Visual Basic for Applications (VBA) is an event-driven, object-oriented programming language for writing
macros, used for the entire Office suite as well as other applications.... this is a definition by stackoverflow :).
Here some posts about Implements in VBA. – dee Aug 6 '15 at 14:27
1 VBA is much like VB from Visual studio version 6 and older. VB now is VB.NET. Much of what is VB.NET is
not in VBA. – MatthewD Aug 6 '15 at 14:34
2 Answers
Abstraction - Abstracting logic and concepts can easily be done by defining objects in
class modules. Strictly speaking, abstraction is also achieved by using meaningful
identifiers and extracting procedural code into methods (class members).
Encapsulation - Classes can have private fields exposed by properties; classes can
be made PublicNotCreatable , effectively exposing types to other VBA projects - and with a
little bit of effort (by exporting the class module, opening it in your favorite text editor,
1 of 1 9/16/2017, 7:06 PM