Mega Code Archive

 
Categories / VB.Net Tutorial / Collections
 

Declaring and allocating an array

Module Tester    Sub Main()       Dim i As Integer       Dim array As Integer()    ' declare array variable       array = New Integer(9) {} ' allocate memory for array       Console.WriteLine("Subscript " & vbTab & "Value")       For i = 0 To array.GetUpperBound(0)          Console.WriteLine( i & vbTab & array(i))       Next       Console.WriteLine("The array contains " & _          array.Length & " elements.")    End Sub      End Module Subscript Value 0 0 1 0 2 0 3 0 4 0 5 0 6 0 7 0 8 0 9 0 The array contains 10 elements.