UBound Function

Returns the upper boundary of an array.

Синтакса

UBound (ArrayName [, Dimension])

Врати вредност:

Цел број

Параметри:

ArrayName: Name of the array for which you want to determine the upper (Ubound) or the lower (LBound) boundary.

[Dimension]: Integer that specifies which dimension to return the upper(Ubound) or lower (LBound) boundary for. If no value is specified, the boundary of the first dimension is returned.

Error codes:

5 Invalid procedure call

9 Subscript out of range

Пример

Sub ExampleUboundLbound

Dim sVar(10 To 20) As String

    Print LBound(sVar())

    Print UBound(sVar())

End Sub

 

Sub ExampleUboundLbound2

Dim sVar(10 To 20,5 To 70) As String

    Print LBound(sVar()) REM Returns 10

    Print UBound(sVar()) REM Returns 20

    Print LBound(sVar(),2) REM Returns 5

    Print UBound(sVar(),2) REM Returns 70

End Sub