Sign in with Microsoft
Sign in or create an account.
Hello,
Select a different account.
You have multiple accounts
Choose the account you want to sign in with.

傳回一個 Long,其中包含 陣列指定維度的最小可用下標。

語法

LBound ( arrayname [, dimension ] )

LBound 函數語法具有下列自變數:

引數

描述

arrayname

必要。 陣列 變數的名稱 ;遵循標準變數命名慣例。

維度

選擇性。 Variant (Long) 。 指出會傳回哪個維度下限的整數。 第一個維度使用 1,第二個維度使用 2,依此類型。 如果 省略維度 ,則會假設為1。


註解

LBound 函數與 UBound 函數搭配使用,以決定數位的大小。 使用 UBound 函數找出數位維度的上限。

LBound 會 針對具有下列維度的陣列傳回下表中的值:

Dim A(1 To 100, 0 To 3, -3 To 4)

聲明

傳回值

LBound(A, 1)

1

LBound(A, 2)

0

LBound(A, 3)

-3


任何維度的預設下限為 0 或 1,視 OptionBase 語句的設定而定。 使用 Array 函數 建立的陣列基數為零;它不受 Option Base 影響。

使用 [調暗]、[私人]、[公開]、[ReDim] 或 [靜態] 語句中的 [件者] 子句來設定維度的陣列,可以具有任何整數值做為下限。

範例

附註: 下列範例示範如何在 Visual Basic for Applications (VBA) 模組中使用此函數。 如需使用 VBA 的詳細資訊,請在 [搜尋] 旁的下拉式清單中選取 [開發人員參考],並在 [搜尋] 方塊中輸入一個或多個字詞。

此範例使用 LBound 函數來判斷數位指定維度的最小可用下標。 使用 Option Base 語句覆寫預設的底陣列下標值 0。

Dim Lower
' Declare array variables.
Dim MyArray(1 To 10, 5 To 15, 10 To 20)
Dim AnyArray(10)
Lower = Lbound(MyArray, 1) ' Returns 1.
Lower = Lbound(MyArray, 3) ' Returns 10.
Lower = Lbound(AnyArray)
' Returns 0 or 1, depending on setting of Option Base.

Need more help?

Want more options?

探索訂閱權益、瀏覽訓練課程、瞭解如何保護您的裝置等等。

社群可協助您詢問並回答問題、提供意見反應,以及聆聽來自具有豐富知識的專家意見。

Was this information helpful?

How satisfied are you with the translation quality?
What affected your experience?
By pressing submit, your feedback will be used to improve Microsoft products and services. Your IT admin will be able to collect this data. Privacy Statement.

Thank you for your feedback!

×