You are on page 1of 3

VB SCRIPT FOR QTP 201 1

VBScript is a interpreted Language. It is a light weight language. VBScript is a light version of Microsoft's programming language Visual Basic. How it Works? When a VBScript is inserted into a HTML document, the Internet browser will read the HTML and interpret the VBScript. The VBScript can be executed immediately, or at a later event. Variable Variable is a virtual container, allocates some space in the memory. We can define the variable in two ways 1. Explicit Declaration. 2. Implicit Declaration. Explicit Declaration By using this type of declaration we can define the variables before starting the code. Dim, Public, Private are the statements to define the variable explicitly. Example: Dim x, Dim z, Dim y, X=10 Y=20 Z=x+y To declare multiple variables at a time we can declare like this Dim x, y, z Implicit Declaration Without initializing a variable by using the statements like dim public, private, directly we can a assign a value to the variable. X=20,y=10;

VB SCRIPT FOR QTP 201 1

Naming convention of variables

Valid Person_age Personage1 Person_age_define

Invalid 88age Person_age8 A b

Should not exceed 255 characters. We should not define the variable as shown below Dim x=10 Msgbox x

Option Explicit When we use this statement in the starting of the code, it will force the declaration of variables explicitly. (or) When we use this statement we cannot define the variables implicitly, if we define the variable implicitly it will throw an error while executing the script. It throws an error like this. Error = variable is undefined variable name Option explicit Dim x, y,z x=10 y=20 a=20 z=x+a msgbox z

VB SCRIPT FOR QTP 201 1


Note: It will throw an error because the variable a is not declared. Data Types Data Types help a Programming Language compiler generate the proper machine instructions from the code that a Programmer types in. There are different types for scripting language. Int-------------------------------------------- 10,20,23,30 Boolean ------------------------------------ True/False Float-----------------------------------------5.65 Empty---------------------------------------not defined any value Null -----------------------------------------assigning a value but not specifying anything String -------------------------------------- Date---------------------------------------- #03/06/1986#

You might also like