Arrays VBScript | Automation Testing QTP/UFT

Arrays VBScript:

Arrays are two types – Static Array & Dynamic Array

ARRAY:

Array is a collection of data with different types of data type.

Syntax:

Where, “ArrayName” is the unique name for the array and “size” is a numeric value that indicates the number of elements in the array dimension within the array.

Example:

It stores 4 values. The array always starts from 0.

Assigning values to the array:

There are two types of arrays: 1. Static Array, 2. Dynamic Array.

Static Array:

It has a specific number of elements. Once assigned, size of a static array can’t be modified at runtime.

Dynamic Array:

Size of a dynamic array can be modified at runtime.

Lower Bound & Upper Bound of Array:

Size of the Array:

Another way to assigning Array:

Syntax:

Example:

REDIM:

It recreates the array and erases all the old data

PRESERVE:

Preserve should be used along with redim. It will retain the old data.

SINGLE DIMENSION ARRAY:

MULTI DIMENSION ARRAY:

Some Examples:

Without Preserve

With Preserve

Redim Preserve with Multi-Dimensional Array

VBScript Series:

VBScript for Automation (QTP/UFT) Testing – Part 1

VBScript for Automation (QTP/UFT) Testing – Part 2

VBScript for Automation (QTP/UFT) Testing – Part 3

VBScript for Automation (QTP/UFT) Testing – Part 4

VBScript for Automation (QTP/UFT) Testing – Part 5

Rajkumar SM is a founder of SoftwareTestingMaterial. He is a certified Software Test Engineer by profession and blogger & youtuber by choice. He has an extensive experience in the field of Software Testing. He writes here about Software Testing which includes both Manual and Automation Testing. He loves to be with his wife and cute little kid 'Freedom'.

Leave a Comment

Share via
Copy link
Powered by Social Snap