Previous | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | Next |
Constant in VB Scripting is a meaningful and specific name that takes the place of a data type like integer or string and never changes. There are two types of constants.
1. Named Constant
2. Built in Constant
Constant is like a variable but unlike variable the value does not change for the constant. It is a permanent value stored in the memory.
Named Constant
You will actually assign a integer or a string to a variable but the value assigned to this variable cannot be changed. It is like a variable but not behave like a variable. The value does not change and it cannot be used as a variable.
As part of the coding convention it is better to write all the constants in upper case even though VB Scripting is case insensitive but for easy understanding it is written and this makes no difference.
Note: The variables are written in lower case. A constant cannot be used as a variable.
You can create user defined constants using the const statement and can be created on numeric and string values giving meaningful names.
Syntax
Const [Name] = [Expression]
Const GREETING = “Welcome to the world of constants”
Const Age = 50
Example
Const GREETING = “Welcome to VB Scripting”
Msgbox GREETING
Previous | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | Next |
No comments:
Post a Comment