Variables
Variables are like containers which holds the data values. A variable specifies the name of the memory location.
How to declare variables
Dim VariableName As Datatype 'variable Declaration
VariableName = value 'Variable Initialization
Naming convention of variables
- Variable names can have only letters (both uppercase and lowercase letters), digits and underscore(
_
). - Variables naming cannot contain white spaces like
first name
which is a invalid variable name. - First letter of a variable should be either a letter or an underscore(
_
). - It is always advisable to give some meaningful names to variables.
Example
Declaring integer variable and assigning value
Dim val As Integer
val = 100
Declaring decimal variable and assigning value
Dim val As Decimal
val = 57.93
Declaring String variable and assigning value
Dim str As String
str = "OneCompiler"
Declaring Boolean variable and assigning value
Dim isValid As String
isValid = true