# 2d array looping

## Recommended Posts

A script like this

```For \$i = 0 To 4 Step +1
\$a[\$i][0] = 47
\$a[\$i][1] = 3
\$a[\$i][2] = 99
Next```

I want to do something like below:

While \$a[\$loop] has data

MsgBox(0, "", \$a[\$loop][0] & " - " & \$a[\$loop][1] & " - " & \$a[\$loop][2])

\$loop += 1

WEnd

i.e.

The looping will be :

MsgBox(0, "", \$a[\$loop][0] & " - " & \$a[0][1] & " - " & \$a[0][2])

MsgBox(0, "", \$a[\$loop][1] & " - " & \$a[1][1] & " - " & \$a[1][2])

MsgBox(0, "", \$a[\$loop][2] & " - " & \$a[2][1] & " - " & \$a[2][2])

MsgBox(0, "", \$a[\$loop][3] & " - " & \$a[3][1] & " - " & \$a[3][2])

MsgBox(0, "", \$a[\$loop][4] & " - " & \$a[4][1] & " - " & \$a[4][2])

But assume that I don't know the max index of \$i

How can I do?

##### Share on other sites

Hello 1224,

I am not sure I fully understand your question or your dilemma, but taking a guess, you want to find a way to get the maximum index of your array. If that is correct look at the function Ubound().

```For \$i = 0 To Ubound(\$a)-1
\$a[\$i][0] = 47
\$a[\$i][1] = 3
\$a[\$i][2] = 99
Next```

Realm

Edit: Fixed typos.

Edited by Realm

My Contributions: Calculate Unix time, or seconds since Epoch, accounting for your local timezone and daylight savings time. RegEdit Jumper: A Small & Simple interface based on Yashied's Reg Jumper Function, for searching Hives in your registry.

##### Share on other sites

Hello 1224,

I am not sure I fully understand your question or your dilemma, but taking a guess, you want to find a way to get the maximum index of your array. If that is correct look at the function Ubound().

```For \$i = 0 To Ubound(\$a)-1
\$a[\$i][0] = 47
\$a[\$i][1] = 3
\$a[\$i][2] = 99
Next```

Realm

Edit: Fixed typos.

yes

##### Share on other sites

My Pleasure, I had the time

My Contributions: Calculate Unix time, or seconds since Epoch, accounting for your local timezone and daylight savings time. RegEdit Jumper: A Small & Simple interface based on Yashied's Reg Jumper Function, for searching Hives in your registry.

## Create an account

Register a new account

• ### Recently Browsing   0 members

×

• Wiki

• Back

• #### Beta

• Git
• FAQ
• Our Picks
×
• Create New...