O'Reilly logo

VBScript in a Nutshell, 2nd Edition by Ron Petrusha, Matt Childs, Paul Lomax

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

LBound Function

Syntax

LBound(arrayname[, dimension])
arrayname

Use: Required

Data Type: Array

The name of the array.

dimension

Use: Optional

Data Type: Long

A number specifying the dimension of the array.

Return Value

A Long.

Description

Determines the lower limit of a specified dimension of an array. The lower boundary is the smallest subscript you can access within the specified array.

Rules at a Glance

If dimension isn’t specified, 1 is assumed. To determine the lower limit of the first dimension of an array, set dimension to 1, to 2 for the second, and so on.

Programming Tips and Gotchas

  • This function appears to have little use in VBScript, since VBScript does not allow you to control the lower bound of an array. Its value, which is 0, is invariable. However, it is possible for ActiveX components created using Visual Basic to return a array with a lower bound other than 0 to a VBScript script.

  • LBound is useful when handling arrays passed by ActiveX controls written in VB, since these may have a lower bound other than 0.

VBScript/VB & VBA Differences

Unlike VBA, there is no Option Base available in VBScript, nor does VBScript support the To keyword in the Dim, Private, Public, and ReDim statements. Therefore, all arrays will have a lower bound of 0.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required