Function Reference

UBound

Returns the size of array dimensions.

UBound ( Array [, Dimension] )

 

Parameters

Array The array variable which is being queried.
Dimension [optional] Which dimension of a multi-dimensioned array to report the size of. Default is 1, which is the first dimension. If this parameter is 0, the number of subscripts in the array is returned.

 

Return Value

Success: Returns the size of the array dimension.
Failure: Returns 0 and sets @error:
1 = Array given is not an array.
2 = Array dimension is invalid.

 

Remarks

Remember that the value returned by UBound is one greater than the index of an array's last element!

 

Related

Dim

 

Example


Dim $myArray[10][20]   ;element 0,0 to 9,19
$rows = UBound($myArray)
$cols = UBound($myArray, 2)
$dims = UBound($myArray, 0)

MsgBox(0, "The " & $dims & "-dimensional array has", _
    $rows & " rows, " & $cols & " columns")

;Display $myArray's contents
$output = ""
For $r = 0 to UBound($myArray,1) - 1
    $output = $output & @LF
    For $c = 0 to UBound($myArray,2) - 1
        $output = $output & $myArray[$r][$c] & " "
    Next
Next
MsgBox(4096,"Array Contents", $output)