LBound - VBScript
Overview
LBound returns the index of the lower boundary of an array.
Syntax
LBound(arrayName)
Parameters
- arrayName: The name of the array.
Options/Flags
None.
Examples
Dim myArray(10)
Debug.Print LBound(myArray) ' Output: 0
Dim myArray(5 to 10)
Debug.Print LBound(myArray) ' Output: 5
Common Issues
Error 9: Invalid subscript range.
This occurs when you try to access an element outside the valid range of the array. Use UBound
to determine the upper boundary of the array.
Integration
With UBound:
Determine the range of an array:
Dim myArray(5 to 10)
Debug.Print LBound(myArray) & " to " & UBound(myArray) ' Output: 5 to 10
Related Commands
- UBound: Returns the index of the upper boundary of an array.
- ReDim: Changes the dimensions of an array.