Thursday, September 2, 2010

Using Variables

Variable is an item holding data that can change during execution of the program. All variables in VBScript are of datatype called Variant.

Declaring Variables
Declaring a single variables
Declaring Multiple variables

Declaring a single variables
We can declare variables using Dim statement or public statement or private statement
Dim Variable1
public Variable2
private Variable3

Declaring Multiple variables
We can declare multiple variables by separating each variable name with a comma.
Dim Coordx, Coordy, Coordz

Standard Rules for Variable Names
  1. Must begin with an alphabetic character (A...Z,a...z) or an underscore character
  2. Cannot contain an embedded period
  3. Must not exceed 255 characters
  4. Must be unique in the scope in which it is declared.
  5. After the first character, variable can contain letters, digits and underscore

Assigning value to Variables

Variable1 = 10

Variable Constants

We can create variable constants using const keyword.

Const Pi = 3.14

Array Variables
An array variables is used to store multiple values in a single variable.
Dim VehicleName(2)
VehicleName(0) = "Volvo"
VehicleName(1) = "Santro"
VehicleName(2) = "Mahindra"

No comments:

Post a Comment