Navigation:  thinBasic Modules > Core > Array functions >

UBound

Previous pageReturn to chapter overviewNext page

 

Description

 

Returns the upper array bound for an array dimension.

 

Syntax

 

n = UBound(ArrayVariable[ (Dimension) ])

n = UBound(ArrayVariable[, Dimension ])

 

Returns

 

Number

 

Parameters

 

Name

Type

Optional

Meaning

ArrayVariable


No

Name of a declared array.

Dimension

Number

Yes

The dimension number inside the array. If no dimension is specified, the first dimension will be used.

 

Remarks

 

For not yet dimensioned array upper bound is always 0 (zero).

 

Restrictions

 

See also

 

LBound,

 

Examples

 

DIM MyArray(4, 8, 3) as LONG

 

MSGBOX 0, UBound(MyArray)     '---Will return 4

MSGBOX 0, UBound(MyArray(1))   '---Will return 4

MSGBOX 0, UBound(MyArray(2))   '---Will return 8

MSGBOX 0, UBound(MyArray(3))   '---Will return 3

 

REDIM MyArray(4, 8, 30)

MSGBOX 0, UBound(MyArray, 3)   '---Will now return 30

 

 

 

© 2004-2008 thinBasic. All rights reserved. Version 1.7.0.0 Web Site: http://www.thinbasic.com