### UBound (array)

Basic and Crystal syntax.

##### Argument

array is an array value, expression or variable.

##### Returns

Number value.

##### Action

UBound returns a Number containing the largest available subscript for the given array.

##### Typical use

Commonly used to obtain the size of an array before using a looping control mechanism to systematically manipulate elements of the array.

##### Examples

The following examples are for both Basic and Crystal syntax:

Rem Basic syntax
Dim simpleArray(10) As Number
formula = UBound(simpleArray)
//Crystal syntax
Local NumberVar Array simpleArray;
Redim simpleArray[10];
UBound(simpleArray)

Returns 10.

Rem Basic syntax
Dim dateArray () As Date
dateArray = Array (CDate(#12/25/1998#), CDate(#12/24/1999#))
formula = UBound(dateArray)
//Crystal syntax
Local DateVar Array dateArray;
dateArray := [CDate(#12/25/1998#), CDate(#12/24/1999#)];
UBound (dateArray)

Returns 2.

##### Comments

- This function is designed to work like the Visual Basic function of the same name.

  Note: Unlike Visual Basic, only 1 dimensional arrays are supported in Seagate Crystal Reports. Also, array subscripts start at 1 in Seagate Crystal Reports and not 0 as is the default in Visual Basic.

- UBound returns 1 for an uninitialized array variable, however, it causes an error to subscript an uninitialized array variable. The reason for this behavior is that at present Seagate Crystal Reports does not support arrays with zero elements. To work around this problem, always initialize your array variables. For example, initialize Global array variables in a formula located in the report header and local array variables within the formula itself.

Seagate Software, Inc. http://www.seagatesoftware.com Please send comments to: techpubs@seagatesoftware.com