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

    In VBScript – Part 3, let’s see the following topics:

    Procedures

    1. Functions
    2. Sub Routine

    Arrays

    vbscript - part 3

    PROCEDURES:

    It is a group/collection of statements which will group together and give the name.

    There are 2 different types of procedures.

    1. Function
    2. Sub Routine

    Function:

    Returns a value

    Syntax:
    Example:

    Sub Routine:

    Returns no value

    Syntax:
    Example:
    Example:
    Note: Parentheses is omitted in the above example, since CALL statement is not used.

    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
    I would like to conclude VBScript – Part 3 here and will start VBScript – Part 4 in the next post.

    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

    Sharing is caring.

    Share on facebook
    Facebook
    Share on twitter
    Twitter
    Share on linkedin
    LinkedIn

    Like This Post?

    We have a lot more where that came from?

    We only send really good stuff occasionally, promise.

    Rajkumar SM

    Leave a Comment

    Your email address will not be published. Required fields are marked *

    Share on facebook
    Share on google
    Share on twitter
    Share on linkedin
    Share on whatsapp

    Recent Posts:

    Scroll to Top
    API Testing eBook

    DOWNLOAD FOR FREE