Over a million developers have joined DZone.

Testing in HP QTP with VB Script

VB Script is used for HP QTP scripting in order to create Test Scripts.

· DevOps Zone

The DevOps zone is brought to you in partnership with Sonatype Nexus. The Nexus suite helps scale your DevOps delivery with continuous component intelligence integrated into development tools, including Eclipse, IntelliJ, Jenkins, Bamboo, SonarQube and more. Schedule a demo today

VB Script is used for HP QTP scripting in order to create Test Scripts. VB Script is a Microsoft language where using for .Net development for Web applications. VB Script is a lightweight language, easy to understand, easy to learn and very easy to prepare QTP Test scripts for QTP framework.

Purpose of VB Script in QTP

1.VB Script coding used in hp QTP Test scripting.

2.VB Script is a Microsoft language.

3.Licensed by a many companies and using for programming Language.

VB Script Data Types

VB Script has only one Data type i.e Variant which is used in vb script.Variant is a type of data type that having different information.Variant used as a Null pointer,Boolean,Byte,Storage purpose..etc

Variable is used as a Array type to store information.We can store different type of data into this variable.Vb Script variable should not exceed 255 characters and must be unique.


VB Script has different variable to declare values or assigned types using Dim,Public,Private statements.

  • Dim - Used for all functions with in the script like global declarations

  • Public - Used for all functions or procedures for all the scripts

  • Private - Used for only for which scripts it has declared.


'Global Variable Declarations

Dim k,l,m

'Assign value to K

K = Inputype("Please Enter k value")

'Assign value to l

l= InputType("Please Enter l value")

'Addition of two integers


'Display Addition value m


Option Explicit is also a variable to declare variables,if Option Explicit used you should declare variables in Test scripts for all the variables.If used Option Explicit it will provide details if variables are not declare under Dim or Public or Private  statements.

VB Script Arrays

Array is a type of storage container which is used to store  the particular fixed size of  values of a single type.The length for array is established at the time of array is created.Array is starts with number 0 for example below.


a[3] means


a[0] = 1

a[1]= 2

a[2] = 3

a[3] = 4

Two Types of Arrays

1.Static Array

2.Dynamic Array

Static Array:

In this Static Array we can mention size of the array while declaring the array. For Example

Dim Value[3]

Value[0] = 1

Value[1] = 2

Value[2] = 3

Value[3] = 4

Dynamic Array

In this type of Array we can change the array size at the type of Test script and we can resize the array size in Dynamic Array.


Dim a()

Suppose if we want to resize the specified array we can use ReDim statement to resize the dynamic array size.

ReDim a(5)

The DevOps zone is brought to you in partnership with Sonatype Nexus. Use the Nexus Suite to automate your software supply chain and ensure you're using the highest quality open source components at every step of the development lifecycle. Get Nexus today

software testing,automation testing,vbscript,test automation,programming languages,web dev,devops

The best of DZone straight to your inbox.

Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}