Two Dimensional Rectangle Array
Imports System
Public Class MainClass
Shared Sub Main(ByVal args As String())
Const rowsUB As Integer = 4
Const columnsUB As Integer = 3
' declare a 4x3 Integer array
Dim rectangularArray(rowsUB, columnsUB) As Integer
' populate the array
Dim i As Integer
For i = 0 To rowsUB - 1
Dim j As Integer
For j = 0 To columnsUB - 1
rectangularArray(i, j) = i + j
Next j
Next i
' report the contents of the array
For i = 0 To rowsUB - 1
Dim j As Integer
For j = 0 To columnsUB - 1
Console.WriteLine( _
"rectangularArray[{0},{1}] = {2}", _
i, j, rectangularArray(i, j))
Next j
Next i
End Sub
End Class
Related examples in the same category