Monday, April 12, 2010

VB Scripting - Variable Declaration


Previous12345678910Next

What is a Variable?

Variable in VB Script is a place holder in the memory used to store some data or information.


The information assigned in the variable is a reserved section in the computer’s memory for storing data. The Memory used is temporary. The information stored in the memory is not permanent.

Rules for VBScript Variable usage


A variable in the VB script cannot start with a numeric value (Ex – 1stvalue). It can be a combination of Alphabets and Numbers together (Value1) or separated by a underscore (Value_1). There is no way you can use arithmetic operators and also space is not allowed because if space is given then VB script will recognize them as two different variables. Below are the basic rules followed while creating a Variable.
  • It must always begin with a letter
  • Should not contain a period (.) or arithmetic operators (+, -, *, /, ^)
  • The max length of the variable is 256 characters

Types of Variable Declaration


In VB Script Variable Declaration happens in two ways:

1. Implicit Declaration.
2. Explicit Declaration.

Assigning values to a Variable


A value to a variable can be assigned either using Implicit Declaration or Explicit Declaration.

Example

Value1=20
Jobtype=“Permanent”

From the above we can see that = is an assignment operator. The left hand side of the expression is the variable name and the right hand side of the expression is the value assigned to the variable.


Previous12345678910Next

No comments:

Post a Comment