UBound function
Ubound( arrayname[,dimension] )
Returns the value of the largest usable subscript for the specified dimension of an array.
Example
' This example demonstrates some of the  features of arrays.  The lower
' bound for an array is 0 unless it is specified or option base is set it
' as is done in this example.
 
Option Base 1
 
Sub Main
   Dim a(10) As Double
   MsgBox "LBound: " & LBound(a) & " UBound: " & UBound(a)
   Dim i As Integer
   For i = 1 to 3
      a(i) = 2 + i
   Next i
   Print a(1),a(1),a(2), a(3)
End Sub