Multidimension arrays

The docs seem to suggest that this should work:

tDim = pData.Ubound(1)

but I get a syntax error

This works

tDim = Ubound(pData,1)

Here are the docs:

[quote]result=Ubound(array[,dimension])
OR
Introduced in 2007r2:
result=array.Ubound(dimension)[/quote]

Am I misunderstanding somewhere?

Thanks

Terry

How is pData defined?

[code] dim tNumOfRows,tNumOfCols,tRow,tCol As Integer
Dim tData(- 1,-1) As String

tNumOfRows = myListbox.ListCount
tNumOfCols = myListbox.ColumnCount

redim tData(tNumOfRows,tNumOfCols)

for tRow = 0 to tNumOfRows - 1
for tCol = 0 to tNumOfCols - 1
tData(tRow,tCol) = myListbox.Cell(tRow,tCol)
next
next

[/code]

[quote=88931:@Terry Heaford]tDim = pData.Ubound(1)
[/quote]
So pData is a function, not a variable. Hence the syntax error.

Sorry my fault for mixing pData with tData

To simplify:

[code] dim tNumOfRows,tNumOfCols,tRow,tCol As Integer
Dim tData(- 1,-1) As String

tNumOfRows = myListbox.ListCount
tNumOfCols = myListbox.ColumnCount

redim tData(tNumOfRows,tNumOfCols)

for tRow = 0 to tNumOfRows - 1
for tCol = 0 to tNumOfCols - 1
tData(tRow,tCol) = myListbox.Cell(tRow,tCol)
next
next

tDim = tData.Ubound(1)

[/code]

The last line of the code above gives the following error while compiling:

[quote]This array method works only for one-dimensional arrays
tDim = tData.Ubound(1)[/quote]

I think it should be:
tDim = tData(1).Ubound

[quote=88946:@Alex von Siebenthal]What if you change to

tDim = Ubound(tData, 1)?[/quote]

This works as I advised in the first post.

[quote=88953:@Andre Kuiper]I think it should be:
tDim = tData(1).Ubound[/quote]

This does not work, I get

[quote]This array has more dimensions than you provided
tDim = tData(1).Ubound[/quote]

Just to advise I am working on a Mac with 10.9.3.

Thanks

Terry

Sorry, i made a mistake in the syntax. :frowning: Glad you saw it. :slight_smile:

I think the documentation must be incorrect and

[quote]OR
Introduced in 2007r2:
result=array.Ubound(dimension)[/quote]

must be obsolete.

I do have a solution as the other method

works

Thanks

Terry

The error message says it:

Yes, well spotted but the documentation says otherwise.