Object-Oriented and Procedure–Driven
Visual Basic for Applications and Visual Basic are both types of Programming languages which are both object-Oriented because they work with objects. Nearly all of these objects will appear on the screen that’s why it called ‘visual’. They are also procedure-driven languages using commands and structures from the Basic programming language to bind object statements into workable applications.
Objects, Properties, Methods and Events
In VBA an object is something within the application which you can manipulate in some way. For an example you can edit a spreadsheet by deleting rows, displaying gridlines and so on. A worksheet is therefore an example of an object and objects have a hierarchy Know as an Object Model. There are 3 ways in which you can manipulate an object and they are:
- By changing its properties so it looks or behaves in a different way
- Make an object perform a task by using a method that is associated with the object
- When an event happens to an object have it run the specific procedure
Objects have properties, methods and events.
Lets take a look at an real life example to help us get a better understanding of the matter. Lets think about a car because we can manipulate it is an object that would mean that:
- Properties of the car would be the make, model, colour and so on.
- Methods are what you can do with the car so accelerate, reverse, turning etc…
- Events are the actions that happen to the car that generate an automatic response from the car. For example, if you remove the keys from the ignition while the cars headlights are on (Event), most cars will sound a warning alarm (response).
In VBA, active describes the item with which your currently working, For example the worksheet cell that you’re editing or formatting in excel is the active cell. The active item is said to have the focus.