LBound Function


LBound Function

Class

Microsoft.VisualBasic.Information

Syntax

     Dim result As Integer = LBound(array[, rank]) 


array (required; any array)

An array with a lower bound that is to be determined.


rank (optional; Integer)

The dimension to assess for a lower bound. If omitted, it defaults to 1.

Description

The LBound function returns the lower limit of the specified dimension of an array. In .NET, all array dimensions have a lower bound of zero, so this function always return zero.

Usage at a Glance

  • If array is uninitialized, LBound generates a runtime error. Compare array to Nothing to prevent this error:

         If (someArray IsNot Nothing) Then        ' ----- OK to use LBound 

  • Since VB.NET does not allow you to change the lower bound of an array, the LBound function appears to be superfluous except for reasons of backward compatibility. However, as the .NET Framework may someday support variable lower bounds, its use is still warranted.

Version Differences

  • In VB 6, with its ability to alter the lower bound of an array, the use of LBound was essential. As of the 2005 release of VB, its use under .NET is optional.

  • The 2005 release of Visual Basic supports a new array declaration syntax that restores the VB 6 style "lower To upper" syntax, as in:

         Dim someArray(0 To 5) As String 

    However, the specified lower bound must still be 0.

See Also

UBound Function




Visual Basic 2005(c) In a Nutshell
Visual Basic 2005 in a Nutshell (In a Nutshell (OReilly))
ISBN: 059610152X
EAN: 2147483647
Year: 2004
Pages: 712

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net