# Information.UBound(Array, Int32)Information.UBound(Array, Int32) Method

## 定義

``public static int UBound (Array Array, int Rank = 1);``
``static member UBound : Array * int -> int``

Array
Array Array

Rank
Int32 Int32

#### 傳回

`Integer`.`Integer`. 指定之維度的註標可以包含的最高值。The highest value the subscript for the specified dimension can contain. 如果 `Array` 只有一個元素，則 `UBound` 會傳回 0。If `Array` has only one element, `UBound` returns 0. 如果 `Array` 沒有任何項目，例如它是零長度字串，則 `UBound` 會傳回 -1。If `Array` has no elements, for example if it is a zero-length string, `UBound` returns -1.

#### 例外狀況

`Array``Nothing``Array` is `Nothing`.

`Rank` 小於 1 或 `Rank` 大於 `Array` 的陣序規範。`Rank` is less than 1, or `Rank` is greater than the rank of `Array`.

## 範例

``````Dim highest, bigArray(10, 15, 20), littleArray(6) As Integer
highest = UBound(bigArray, 1)
highest = UBound(bigArray, 3)
highest = UBound(littleArray)
' The three calls to UBound return 10, 20, and 6 respectively.
``````

## 備註

``````Dim a(100, 5, 4) As Byte
``````

`UBound(a, 1)` 100100
`UBound(a, 2)` 55
`UBound(a, 3)` 44

``````Dim total As Integer
total = (UBound(A, 1) + 1) * (UBound(A, 2) + 1) * (UBound(A, 3) + 1)
``````