LBound (function)


LBound(ArrayVariable() [,dimension])


Returns an Integer containing the lower bound of the specified dimension of the specified array variable.


The dimension parameter is an integer specifying the desired dimension. If this parameter is not specified, then the lower bound of the first dimension is returned.

The LBound function can be used to find the lower bound of a dimension of an array returned by an OLE automation method or property:

  LBound( [,dimension])

  LBound(object.method [,dimension])


Sub Main()
  'This example dimensions two arrays and displays their lower bounds.

  Dim a(5 To 12)
  Dim b(2 To 100,9 To 20)

  lba = LBound(a)
  lbb = LBound(b,2)
  MsgBox "The lower bound of a is: " & lba & " The lower bound of b is: " & lbb


  'This example uses LBound and UBound to dimension a dynamic array to
  'hold a copy of an array redimmed by the FileList statement.

  Dim fl$()
  FileList fl$,"*.*"
  count = UBound(fl$)
  If ArrayDims(a) Then
    Redim nl$(LBound(fl$) To UBound(fl$))
    For x = 1 To count
      nl$(x) = fl$(x)
    Next x
    MsgBox "The last element of the new array is: " & nl$(count)
  End If
End Sub

See Also

UBound (function); ArrayDims (function); Arrays (topic).

More information