Navigation:  ThinBASIC Modules > Core (thinBasic Core Engine) > Array functions >

CountOf

Previous pageReturn to chapter overviewNext page

 

Description

 

Returns the number of elements of an array dimension

 

Syntax

 

n = CountOf(ArrayVariable[ (Dimension) ])

n = CountOf(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 arrays functions will return 0 (zero).

 

Restrictions

 

See also

 

LBound, UBound, CountOf,

 

Examples

 

DIM MyArray(4, 8, 3) as LONG

 

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

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

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

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

 

REDIM MyArray(4, 8, 30)

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