# How to create a Multidimensional Array?

**URL:** <https://forum.xojo.com/t/how-to-create-a-multidimensional-array/26225>\
**Category:** Getting Started\
**Created:** [August 21, 2015, 11:05pm UTC](https://forum.xojo.com/t/how-to-create-a-multidimensional-array/26225 "2015-08-21T23:05:12Z")\
**Posts on this page:** 7\
**Page:** 2

<div class="post-metadata">

**Author:** ![Tim\_Hare](https://forum.xojo.com/user_avatar/forum.xojo.com/tim_hare/32/176_2.png) [@Tim\_Hare](https://forum.xojo.com/u/Tim_Hare)\
**Post date:** [November 25, 2015, 11:21pm UTC](https://forum.xojo.com/t/how-to-create-a-multidimensional-array/26225/21 "2015-11-25T23:21:19Z")

</div>

You’re using Ubound incorrectly. The second parameter is which dimension to get the bounds for. Your array only has 2 dimensions, not 3.

Ubound(MatrizCFDI, 1) = number of rows  
Ubound(MatrizCFDI, 2) = number of columns

Since you appear to want z to iterate over rows, your code should be

```auto
For z As Integer = 1 to Ubound(MatrizCFDI, 1)
   Msgbox MatrizCFDI(z, 3)
Next
```

As an aside, did you intend to skip MatrizCFDI(0, 3)?

---

<div class="post-metadata">

**Author:** ![Gerardo\_Garca](https://forum.xojo.com/letter_avatar_proxy/v4/letter/g/e99b99/32.png) [@Gerardo\_Garca](https://forum.xojo.com/u/Gerardo_Garca)\
**Post date:** [November 25, 2015, 11:27pm UTC](https://forum.xojo.com/t/how-to-create-a-multidimensional-array/26225/22 "2015-11-25T23:27:57Z")

</div>

[quote=232071:@Tim Hare]You’re using Ubound incorrectly. The second parameter is which dimension to get the bounds for. Your array only has 2 dimensions, not 3.

Ubound(MatrizCFDI, 1) = number of rows  
Ubound(MatrizCFDI, 2) = number of columns

Since you appear to want z to iterate over rows, your code should be

```auto
For z As Integer = 1 to Ubound(MatrizCFDI, 1)
   Msgbox MatrizCFDI(z, 3)
Next
```

As an aside, did you intend to skip MatrizCFDI(0, 3)?[/quote]  
But I Write it without problems:

[b]  
CountLink As Integer = 478  
ReDim MatrizCFDI(Countlink, 3)

For i as Integer =1 to countLink -1

```
MatrizCFDI(i,3) = Replace(Replace(NthField(NthField(SourceCFDi,filtro, i+1), ";""", 1),"return AccionCfdi('","https://portalcfdi.facturaelectronica.sat.gob.mx/"),"','Recuperacion')","")

```

Next[/b]

But I decided to write at 3th column.

Because I need to write the "Download LINKS Info " in Column 3

In Column 2 -\> “Name of the File”  
In Column 1 -\> “Name of The Company Emitter”  
In Column 0 -\> “Date of the Document”

But Now I have values written on 3th Column I Wanna consult it.

Thanks

---

<div class="post-metadata">

**Author:** ![Tim\_Hare](https://forum.xojo.com/user_avatar/forum.xojo.com/tim_hare/32/176_2.png) [@Tim\_Hare](https://forum.xojo.com/u/Tim_Hare)\
**Post date:** [November 25, 2015, 11:31pm UTC](https://forum.xojo.com/t/how-to-create-a-multidimensional-array/26225/23 "2015-11-25T23:31:12Z")

</div>

You seem to be confusing Index with Dimension. Ubound works on Dimension. You extract the data based on Index.

Dim my2dArray(100, 20, 5)  
msgbox(str(Ubound(my2dArray, 1)) // 100  
msgbox(str(Ubound(my2dArray, 2)) // 20  
msgbox(str(Ubound(my2dArray, 3)) // 5

x = my2dArray(92, 17, 2)

---

<div class="post-metadata">

**Author:** ![Tim\_Hare](https://forum.xojo.com/user_avatar/forum.xojo.com/tim_hare/32/176_2.png) [@Tim\_Hare](https://forum.xojo.com/u/Tim_Hare)\
**Post date:** [November 25, 2015, 11:34pm UTC](https://forum.xojo.com/t/how-to-create-a-multidimensional-array/26225/24 "2015-11-25T23:34:12Z")

</div>

[quote=232073:@Gerardo García]CountLink As Integer = 478  
ReDim MatrizCFDI(Countlink, 3)[/quote]  
Here, Ubound(MatrizCFDI, 1) is CountLink, and Ubound(MatrizCFDI, 2) is 3.  
So

```auto
for z = 1 to CountLink
```

is equivalent to

```auto
for z = 1 to Ubound(MatrizCFDI, 1)
```

---

<div class="post-metadata">

**Author:** ![Tim\_Hare](https://forum.xojo.com/user_avatar/forum.xojo.com/tim_hare/32/176_2.png) [@Tim\_Hare](https://forum.xojo.com/u/Tim_Hare)\
**Post date:** [November 25, 2015, 11:36pm UTC](https://forum.xojo.com/t/how-to-create-a-multidimensional-array/26225/25 "2015-11-25T23:36:34Z")

</div>

Also, your examples are a little sloppy about the boundaries of the array. You tend to be off by one. For example

> [@](#):
>
> For i as Integer =1 to countLink -1

skips a value on either end of the range.

---

<div class="post-metadata">

**Author:** ![Tim\_Jones](https://forum.xojo.com/user_avatar/forum.xojo.com/tim_jones/32/8627_2.png) [@Tim\_Jones](https://forum.xojo.com/u/Tim_Jones)\
**Post date:** [December 17, 2017, 11:40pm UTC](https://forum.xojo.com/t/how-to-create-a-multidimensional-array/26225/26 "2017-12-17T23:40:58Z")

</div>

Digging through the old posts looking for something else and I found this. I referenced back to the User guide and it seems that something like this discussion would be very helpful if boiled down to specifics. This is the sum total of info in the user’s guide under Arrays:

```auto
Multi-Dimensional Arrays

A multi-dimensional array has elements in 2 or more dimensions. A table would be an example of a 2-dimensional array because it has columns and rows.

Most of the array methods are not supported for multi-dimensional arrays.

You declare multi-dimensional arrays by specifying the upper bound for each dimension:

' A 5x5 table
Dim table(4, 4) As Integer
table(1, 3) = 42
```

---

<div class="post-metadata">

**Author:** ![system](https://forum.xojo.com/uploads/default/original/1X/455b4dcc0e61630e9f81940004ddffa49c432a46.png) [@system](https://forum.xojo.com/u/system)\
**Post date:** [October 29, 2020, 5:54pm UTC](https://forum.xojo.com/t/how-to-create-a-multidimensional-array/26225/27 "2020-10-29T17:54:25Z")

</div>



[Previous page](https://forum.xojo.com/t/how-to-create-a-multidimensional-array/26225.md?page=1)
