Thanks:  0
Likes:  0
Dislikes:  0

# Thread: Iterate the two diemsntional Array

1. ## Iterate the two diemsntional Array

How can I Iterate the two diemsntional Array and reterive the the vales from it.

2. ## Re: Iterate the two diemsntional Array

you can create multiple loops and check out that way.

is your array MyArray(10) or MyArray(5,10)??

3. ## Re: Iterate the two diemsntional Array

It can be n number of rows and n number of coulmns. It is not known how many rows , columns it will be.

So how to determine the length of number of rows and coumns the 2 dimentional array in both Arrays. one dimentional I know how to do it.what about 2 domenational array.

4. ## Re: Iterate the two diemsntional Array

You would use something like (VBScript):

for i = 0 to UBound( MyArray )

for j = 0 to UBound( MyArray, i )

arrayvalue = MyArray( i, j )

next

next

To get the number of items in a 2-d array, you can use UBound with the extra argument.

Hope this helps

5. ## Re: Iterate the two diemsntional Array

Hi,

What scripting language do you use and how do you create your array? The way to determine the array size and iterate through items may depend on this.

6. ## Re: Iterate the two diemsntional Array

Thanks. I will try and update you.

7. ## Re: Iterate the two diemsntional Array

Hi Jared. It is VbScript.

8. ## Re: Iterate the two diemsntional Array

Hi Jared , I get Script out of range error message for the line for j = 0 to UBound(MyArray, i ) in the following code.

Function getdata()
Dim DbArray()
rowcount=2
columnacount=5
ReDim DbArray(rowcount,columnacount)
For i=1 to rowcount
For j=3 to columnacount
DbArray(i,j)=Browser("qa Jobs at Dice.com").Page("qa Jobs at Dice.com").WebTable("Job Title").GetCellData(i,j)

Next

Next

getdata=DbArray
End Function

MyArray=getdata()

for i = 0 to UBound(MyArray)

for j = 0 to UBound(MyArray, i )

arrayvalue = MyArray( i, j )
msgbox arrayvalue

next

next

9. ## Re: Iterate the two diemsntional Array

This gotta be either 1 or 2 since you have 2 deferential array. in your case it is like this.

for j = 0 to UBound(MyArray, 2) 'This will loop up to 5

10. ## Re: Iterate the two diemsntional Array

VBScript arrays start with index 1.

I find 2 dimentional arrays in VBScript annoying to work with. When you need to resize it, you end up having to ReDim the whole thing which can be very expensive for large arrays. I prefer to use arrays of arrays to simulate multi dimentional arrays.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•
Search Engine Optimisation provided by DragonByte SEO v2.0.36 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Resources saved on this page: MySQL 9.09%
vBulletin Optimisation provided by vB Optimise v2.6.4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.2.8 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
vBNominate (Lite) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Feedback Buttons provided by Advanced Post Thanks / Like (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Username Changing provided by Username Change (Free) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
BetaSoft Inc.
Digital Point modules: Sphinx-based search
All times are GMT -8. The time now is 07:06 PM.

Copyright BetaSoft Inc.