Show and use the array boundaries : Array Bound « Collections « VB.Net Tutorial






public class Test
   public Shared Sub Main
        Dim aryNames(9) As String
        Dim intCounter As Integer

        'Show the array boundaries.
        Console.WriteLine("LOWER BOUND: " & aryNames.GetLowerBound(0))
        Console.WriteLine("UPPER BOUND: " & aryNames.GetUpperBound(0))
        Console.WriteLine("LENGTH: " & aryNames.Length)

        'Populate the array.
        For intCounter = 0 To aryNames.GetUpperBound(0)
            aryNames(intCounter) = "Element position = " & intCounter
        Next intCounter

        'Show the elements of the array.
        For intCounter = 0 To aryNames.GetUpperBound(0)
            Console.WriteLine("Element position = " & intCounter)
        Next intCounter


   End Sub


End class
LOWER BOUND: 0
UPPER BOUND: 9
LENGTH: 10
Element position = 0
Element position = 1
Element position = 2
Element position = 3
Element position = 4
Element position = 5
Element position = 6
Element position = 7
Element position = 8
Element position = 9








8.2.Array Bound
8.2.1.Show and use the array boundaries
8.2.2.Use array UBound in For loop
8.2.3.GetUpperBound
8.2.4.Array lower bound and upper bound
8.2.5.Get array lower bound, upper bound and length