1.2. Multi-dimensional Static Array ‘Exp – Dim myArray(3,4)
2. Dynamic or Variable Sized Array
2.1. Single dimensional Dynamic Array
2.2. Multi-dimensional Dynamic Array
myArray(0)= 21
myArray(1)= 42
myArray(2)= 51
myArray(3)= 33
myArray(4)= 15
It was one way of declaring and assigning values to an array.
Here is the another way…
Dim myArray
myArray = Array(21,42,51,33,15) ‘integer values
myArray = Array(“val1″,”val2″,”val3″,”val4″,”val5”) ‘string values
myArray = Array(“1″,2,”val3″,4,”val5”) ‘mix of num and string values
As I mentioned above as well, VBScript explicitly supports only one data type – ‘Variant’. A variant can store a number as well as a string.
It was the VBScript Array Method of Creating Arrays.
Array we have discussed above is Static Array – Single dimensions. A Static Array –
– has a pre-defined number of elements.
– size of a static array cannot be altered at run time.
Dim myArray(4,6)
In the above example, an array containing 5 rows and 7 columns has been declared.
Calculating the Size of Arrays:
ubound method is used to count the length of array. It returns the highest index number of the array.
But remember, the actual size of the array is highest index number plus one!! (since the array starts at index number 0).
Dim myArray(4), len1
len1 = ubound(myArray) ‘4
msgbox “Length of the Array is: ” & len1+1 ‘output is 5
ubound method can be used to count the size of a multidimensional array also, but this time it’s slightly different..
The dimension number needs to be included in ubound.
Dim myArray(4,6)
msgbox ubound(myArray, 1) ‘shows highest index of the first dimension – 4
msgbox ubound(myArray, 2) ‘shows highest index of the second dimension – 6
Tired! me too…!!
Hey Abhi…
Its quite helpful and elaborative just like class room session.
Good stuff!!
@Smiles
thanks!! keep reading the good stuff!
thanks for valuable information……………
I have gone through multiple sites for learning an array in QTP , and it was not of much use , but the way you have explained it is in simple words and easy to understand, have never written any commentc for anything till date ,and this is the 1st time ever Im writting a comment as I was really impressed by your explanation.
Keep up the good work and expecting more on QTP scripting.
Thanks
Good Stuff..!!
Hi
I don't ur name
But what u r explaining is very useful n very easy to understand
Thanks
very nice
reallly great
Supreb. Keep posting.
fantastic stuff
simply great dude! keep up the good work!
hi Abhi,
Thanks for valuable information.
can pl explain how can we enter alues in multi dimentional static array
Thank you for the awesome information… guess what I love the pink backgroung 😀
so much impressed and easily understandable…
how to click a multiple object dynamically in qtp example i want to click multiple webbutton dynamically?
Thanks for your information, very useful 😀
can you please explain wat is ubound and its function
Even i follow the exact process…
Abhi,
You are just..too good.