Get Array Lower Boundary Method
The Get Array Lower Boundary method returns the lowest index number of the dimension that the dimension argument identifies. The numbering for each dimension of an array starts at 1. If you do not include the dimension argument, then it uses 1 is the default.
You can use the Get Array Lower Boundary method with the Get Array Upper Boundary method to determine the length of an array.
Format
LBound(arrayname [, dimension] )
The following table describes the arguments that you can use with this method.
Argument | Description |
---|---|
arrayname |
The name of the array to query. |
dimension |
The dimension to query. |
Example
The following example resizes an array if the user enters more data than this array can hold. It uses the LBound statement and the UBound statement to determine the existing size of the array. It uses the ReDim statement to resize the array. The Option Base statement sets the default lower boundary of the array to 1:
Option Base 1
Sub Button_Click
Dim arrayvar() as Integer
Dim count as Integer
Dim answer as String
Dim x, y as Integer
Dim total
total = 0
x = 1
count = 4
ReDim arrayvar(count)
start:
Do until x = count + 1
arrayvar(x) = 98
x = x + 1
Loop
x = LBound(arrayvar,1)
count = UBound(arrayvar,1)
For y = x to count
total = total + arrayvar(y)
Next y
End Sub