Vous êtes sur la page 1sur 1

excel - Is VBA an OOP language, and does it support polymorphism? - S... https://stackoverflow.com/questions/31858094/is-vba-an-oop-language-a...

x Dismiss

Join the Stack Overflow Community

Stack Overflow is a community of 7.7 million


programmers, just like you, helping each other.
Join them; it only takes a minute:

Sign up

Is VBA an OOP language, and does it support polymorphism?

I am actually working on my first VBA project. (come from C++)

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.

Some of them propose a workaround using the keyword Implements.

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 :

Is VBA an OOP language, and does it support polymorphism ?

excel vba oop polymorphism

edited Aug 6 '15 at 17:43 asked Aug 6 '15 at 14:13


Robert Harvey Axel Borja
137k 30 243 374 1,302 3 18 36

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

1 Here good example with Implments . – dee Aug 6 '15 at 14:35

1 And here some more informations. – dee Aug 6 '15 at 14:37

2 Answers

OOP is sitting on 4 "pillars":

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

Vous aimerez peut-être aussi