User FAQs

If you have a question, please send it to us.


1) What is Object Orientated programming ?
This is a style of programming that is based on objects containing methods, properties and events arranged in a hierarchy.
This type of programming is based around four key features:
Polymorphism - Create routines that can operate on objects of different types. This is handled by late binding and multiple interfaces.
Encapsulation - Hide parts of the implementation and hide complexity. This is achieved using access modifiers.
Inheritance (Interface) - (Public Inheritance) Define methods (without implementation) that must be declared in a derived class.
Inheritance (Implementation) - (Private Inheritance) Inherit method implementation from a base class.


2) Is VBA an Object Oriented programming language ?
No. It does not have implementation inheritance which is the ability to inherit method implementation from a base class.
You can incorporate interface Inheritance by using the Implements keyword.
You can incorporate Polymorphism by using late binding and the Object data type.
You can incorporate Encapsulation by using the private access modifier inside a class.


3) What is a Class module and how is it different from a Standard module ?
A class module is a special type of module that allows you to create your own customised objects with their own methods, properties and events.
Class module data exists for each instance of the class.
A standard module can contain subroutines and functions which can be accessed from anywhere in the project.
Standard modules are used to store variables, constants and declarations (APIs).


4) How would you create a class in VBA ?
A class module lets you create your own classes and interfaces.
The module name is the name of the class or interface.
Userforms are a type of class module although they behave slightly differently to the ones that you can create.


5) What is an Interface class ?
An interface class defines a set of declarations (properties and methods) which have to be implemented in a class.


6) Can you define an Interface that contains one read/write property and one method ?
Class module - MyInterface.

Public Property Get Property_Name() As String 
End Property

Public Property Let Property_Name(ByVal sValue As String)
End Property

Public Sub MyMethod()
End Sub

7) What is the difference between Property Let and Property Set ?
Let is for value data types
Set is for reference data types

Public Property Let Property_Name(ByVal sValDataType As String) 
   valField = sValDataType
End Property

Public Property Set Property_Name(ByVal oRefDataType As Object)
   Set privateField = oRefDataType
End Property

8) When would you use the 'Implements' keyword ?
Class module - MyClass

Implements MyInterface 

Public Sub MyMethod()
End Sub

Never use Implements behind an Excel Worksheet.


9) Can you describe the Class_Initialize and Class_Terminate subroutines ?
Class_Initialize - This event will occur when an instance of a class is created.

Set ref1 = New MyClass 

Class_Terminate - This event will occur when an instance of a class is destroyed.

Set ref1 = Nothing 

10) What is a Userform/Form and why would you use one ?
Userforms are custom user interface screens.
A userform is a dialog box that can be used for data entry or displaying information.
A userform is a type of class module.
When you add a Userform to a project the following reference is added automatically.
Microsoft Forms 2.0 Object Library.


© 2021 Better Solutions Limited. All Rights Reserved. © 2021 Better Solutions Limited TopPrevNext