It is based on the Visual Basic
Supports object oriented features
It is Interpreted by the browser
Loosely Typed
It is used to create the dynamic and interactive website
In ASP (Active Server Pages) VBScript is used as a server side script language.
Adding VBScript Code to an HTML Page
The SCRIPT element is used to add VBScript code to an HTML page.
Syntax:
VBScript – Language Fundamentals
Syntax Rules
VBScript is not case sensitive (except for Strings)
Each statement can only exist on one line
Statements can be either simple statements or compound statements
Comments
Syntax
‘ (Single quote) – Comment Symbol
Can be a complete line or a portion of a line.
VBScript does not support multi-line comments. The comment symbol must be put at the start of each comment.
Naming Rules
Must begin with a letter or the underscore
valid: count, strInfo, _data
Invalid: 2day, 4get, *count violate this rule.
Cannot contain special characters except the underscore
valid: Names using alphabets, numbers and the underscore.
Invalid: Names using symbols and other special characters.
Naming Rules
Cannot match a reserved word
Example: for, if, Select
Must be unique within a context
Must be less than 256 characters
VBScript Variables and Data Types
Variables
Variables hold values that can change during program execution
They function just like temporary storage locations
Declaration of variables is optional, but recommended
The Option Explicit statement is available to require explicit declaration of all variables.

Dim, Public and Private Statements are used to explicitly declare the variables.
Syntax:
Dim variableName
Assigning the Value to the Variable
=
Example:
Dim stud_name – Variable Declaration
stud_name = “Sanjay” – Assigning the value
Constants
Constant names hold values that cannot change during program execution
Constants should be used in place of hard-coded values
Syntax:
Const constantName = value
VBScript Data Types
VBScript has only one data type called a Variant which contains either numeric or string information.
VBScript interprets a variant in a manner that is suitable to the type of data it contains.
The different categories of information that can be contained in a Variant are called subtypes.

VBScript Operators
Type of Operators
Arithmetic Operators
Comparison Operators
Logical Operators


Arithmetic Operator
Used to perform calculations
Both operands must be numeric values
The result is a numeric value
Comparison
Used to compare the value of two items
Both operands must be of the same data type
The result is a Boolean value
Logical Operator
Used to reduce Boolean values into a single Boolean value
Both operands must be Boolean values
The result is a Boolean value