dim and redim

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

The distinction between 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 coordinates.
Peruse Array class and idea in Java here.
The array has two important concepts

  • Upper bound – it Signifies 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 to 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.

READ  XSS

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.

The second technique to creating 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 is beforehand present in the cluster is all things considered while changing the measurement utilizing ReDim watchword.

Concept-I

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.

Concept-II:

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

READ  How to Work With Arrays in VBScript or UFT?

Share and Enjoy !

8 thoughts on “Difference between Dim and Redim Statement In VBScript,UFT,QTP”

  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.

  2. I’ve been surfing on-line greater than 3 hours today, but I by no means found any interesting article
    like yours. It’s pretty price sufficient for me. In my view, if all webmasters and bloggers made good content material as you did, the
    web will be a lot more helpful than ever before.

  3. Hey there, You have done an incredible job. I’ll definitely digg it and personally
    recommend to my friends. I’m confident they will be benefited from this website.

  4. Hello my loved one! I wish to say that this post is awesome, great written and come with approximately all vital infos.

    I would like to look extra posts like this .

  5. Why people still make use of to read news papers when in this technological world everything is existing on web?

  6. lashawnda_kimbell

    Good information. Lucky me I came across your site by accident (stumbleupon).
    I’ve saved as a favorite for later!

Leave a Comment

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