array.Length Property

Returns the total number of elements in an entire array.

...array.Length

Prerequisites

None

Parameters

None

Remarks

In GPL, all array dimension indices start at 0 and end at the upper bound. The Length may be computed by multiplying (1+upper bound) of all array dimensions.

Do not be confused when using the Length property with String arrays.  For example, if you declare: Dim sarray(3) AsString.

sarray.Length is the number of elements in the array, in this case 4 (from 0 to 3).
sarray(0).Length is the length of the string contained in sarray(0), initially 0.

Examples

Dim array(3,4) As Integer
Dim length As Integer
length = array.Length ' Returns the value 20 = (1+3)*(1+4)

See Also

Array Class |array.GetUpperBound|Dim Statement|ReDim Statement