|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:
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.
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 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
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 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.