Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
If you are declaring an array, you can specify the lower bound of each dimension using the zero character (0) with the To keyword. This does not change the required lower bound, but it can make your code easier to read.
Declare the array in the normal way.
Inside the parentheses, add 0 To in front of the upper bound for each dimension.
Public Sub declarelowerbounds() Dim monthtotal(0 To 11) As Double Dim cell(0 To 39, 0 To 19) As Integer MsgBox("Total number of elements:" _ & vbCrLf & "monthtotal (0 To 11) length " & CStr(monthtotal.Length) _ & vbCrLf & "cell (0 To 39, 0 To 19) length " & CStr(cell.Length)) End Sub
The lower bound must always be 0, but your code can be more readable when you explicitly declare it. Specifying both bounds also reminds the reader that the lower bound is 0.
Alternative Array Creation. You can create an array without using the Dim Statement (Visual Basic) or the New (Visual Basic) clause. For example, you can call the CreateInstance method, or another component can pass your code an array created in this manner. Such an array can have lower bounds other than 0. You can always test for the lower bound of a dimension with the GetLowerBound method or the LBound Function (Visual Basic).