Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

LBound Function

Returns the lowest available subscript for the indicated dimension of an array.

Public Function LBound( _
   ByVal Array As System.Array, _
   Optional ByVal Rank As Integer = 1 _
) As Integer

Parameters

Array
Required. Array of any data type. The array in which you want to find the lowest possible subscript of a dimension.
Rank
Optional. Integer. The dimension for which the lowest possible subscript is to be returned. Use 1 for the first dimension, 2 for the second, and so on. If Rank is omitted, 1 is assumed.

Exceptions/Errors

Exception type Error number Condition
ArgumentNullException 9 Array is Nothing.
RankException 9 Rank < 1 or Rank is greater than the rank of Array.

Remarks

Since array subscripts start at 0, the lowest available subscript for every dimension is always 0.

For an array with the following dimensions, LBound returns the values in the following table:

Dim A(100, 5, 4) As Byte
Call to LBound Return value
LBound(A, 1) 0
LBound(A, 2) 0
LBound(A, 3) 0

Example

This example uses the LBound function to determine the lowest available subscript for the indicated dimension of an array.

Dim Lowest, MyArray(10, 15, 20), AnyArray(6) as Integer
Lowest = LBound(MyArray, 1)   ' Returns 0.
Lowest = LBound(MyArray, 3)   ' Returns 0.
Lowest = LBound(AnyArray)   ' Returns 0.

Requirements

Namespace: Microsoft.VisualBasic

Module: Information

Assembly: Microsoft Visual Basic .NET Runtime (in Microsoft.VisualBasic.dll)

See Also

UBound Function | Dim Statement | ReDim Statement | ArgumentException Class | RankException Class

Show:
© 2015 Microsoft