Google News
logo
Management Information System (MIS) - Interview Questions
What is the difference between DIM and SET?
The terms "DIM" and "SET" can have different meanings depending on the context in which they are used. However, in programming, especially in languages like Visual Basic for Applications (VBA), they often refer to similar concepts related to variable declaration and assignment:

DIM : In VBA, "DIM" is a keyword used to declare variables. When you declare a variable using DIM, you are essentially specifying its data type and optionally allocating memory for it.

Example :
Dim x As Integer?

This statement declares a variable named "x" of type Integer.
SET :  In VBA, "SET" is a keyword used to assign object references to variables. It is used specifically when working with objects, such as forms, worksheets, or ranges.

Example :
Dim ws As Worksheet?

Set ws = ThisWorkbook.Worksheets("Sheet1")

This code declares a variable named "ws" of type Worksheet and assigns a reference to the worksheet named "Sheet1" in the current workbook to it.

DIM is used for variable declaration and assignment of non-object data types, while SET is used for assigning object references to variables.
Advertisement