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) Can you describe when you would use Property Get ?
Lets you return the value of a private variable (or field) from inside a class.

Private field_sDepartment As String 
Public Property Get Property_Department() As String
   Property_Name = field_sDepartment
End Property

6) Can you use Property Get in a Standard module (not a Class module) ?
Yes. Although this is not recommended and will cause a lot of confusion.
Property procedures should only be used inside Class modules.
Instead of using Property Get use a Public variable or a Private variable and a Public function.

Public g_Something As String 

Private m_Something As String
Public Function Something() As String
   Something = m_Something
End Function

7) 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 Method_One()
End Sub

8) 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

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


10) When would you use the Friend keyword ?
This cannot be used in a standard module.
Not accessible to other referencing VBA projects.

Friend sText As String 

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

Implements Interface_My 

Public Sub Method_One()
End Sub

Never use Implements behind an Excel Worksheet.


12) 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 

13) 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.


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