Spread the love

Difference between Dim and Redim Statement In VBScript,UFT,QTP

Spread the love

Difference between Dim and Redim Statement In VBScript,UFT,QTP
Difference between Dim and Redim Statement In VBScript,UFT,QTP

Distinction among Dim and Redim Statement In VBScript,UFT,QTP:

Array Concept in VBScript:

Concept of Plain Array in VBScript:

While the plain Variant or variable has one memory square to store one specific value,the Array has a few memory squares or compartments to store different values.Array speaks to the line and segment (rows and column)concept(not fully,just sort of). 
Arrays are utilized to store some sort of Objects when we know the span of the Objects upfront.A VBScript Array can hold up to 60 dimensions(Array sections are known as dimensions).Two or three dimensional exhibit implies it can speak to an incentive in x,y or x,y,z co ordinates. 
Peruse Array class and idea in Java here

Array has two important concepts

  • Upperbound – it Signify what number of most extreme memory hinder a cluster can hold. 
  • LowerBounds-it Signify what number of least memory obstruct an exhibit can hold.it is frequently alluded as zero(0).LowerBounds zero alludes to a zero based cluster. 

VBScript arrays constantly zero based so we require tell the VBScript motor what is the UpperBounds esteem for the cluster.

Dim myArray(5) ' will dependably hold 6 component as it begins from zero.

Dynamic Array:

Plain array functions admirably when we know the span of the information forthright that the array is going to hold.In case we don’t have the foggiest idea about the information estimate previously,we can make utilization of Dynamic array in VBScript. 

Deceleration of Dynamic Array:

Dim myArray() ' an unfilled enclosure will make a dynamic array.we require
'to give the upper bound amid the runtime.

This is a mainstream method to maintain a strategic distance from hard coding in the content.

READ  How to Work With Network with VBScript using WSH?
READ  VB Script Procedures and Functions

The second technique to create a Dynamic Array

Dim myArray(5) ' will always hold 6 element as it starts from zero.
ReDim myArray(10)' Array size increased to 11.

So the ReDim explanation is utilized to change the cluster measure inside the content, for instance…
on the off chance that we have announced an array diminish client (30)
in any case, after that we need to change the extent of the array, we can do it with the assistance of Redim explanation

like-Redim customer(100)

Note: Redim explanation clears all components present in the exhibit variable so if our cluster contains some data,once we apply ReDim,all information will be gone.If we would prefer not to free the information we can utilize another catchphrase called-Preserve. .

Preserve keyword

Preserve keyword catchphrase guarantees that the information which are beforehand present in the cluster is all things considered while changing the measurement utilizing ReDim watchword.


ReDim for the most part used to expanded the measurement however we can utilize ReDim to resize to littler size than the present cluster size.In that case Preserve watchword won’t make any difference.Redim to a lower size will at any rate chop down the additional memory squares of the exhibit to abbreviate the size.


While working with Preserve keyword,we can just resize the last measurement or the last memory block.If an endeavor is made to resize some other dimension,VBScript Engine will create some blunder (throw an error I mean!!)

Spread the love
Animesh Chatterjeehttps://techtravelhub.com/
I am the founder and owner of the blog - TechTravelHub.com, always love to share knowledge on test automation,tools,techniques and tips.I am a passionate coder of Java and VBScript.I also publish articles on Travel ideas and great honeymoon destinations.Apart from these, I am a gear-head,love to drive across India. I have shared lots of articles here on How to travel several parts of India.Customization of cars aka car modification is my another hobby.Get in touch with me on ani01104@gamil.com

Related Articles

Learn File System Object(FSO) in UFT or QTP or VBScript Free

This post will cover the File System Object(FSO) in UFT. File...


  1. Hi there every one, here every person is sharing these
    kinds of experience, thus it’s pleasant to read this webpage, and I
    used to pay a quick visit this website everyday.


Please enter your comment!
Please enter your name here

Recent Posts

Learn Quickly About DevOps Tools in a Fast and Efficient Manner

Introduction to DevOps tools DevOps tools are a collection of...

How to Collaborate between Development and Operations Team Fast and Effectively

Collaborate between Development and Operations Teams are the key...

Learn How to Use Jacoco Java code Coverage

Introduction to Jacoco Jacoco provides a wide range of coverage(analysis...


Spread the love