VB Two Dimensional Arrays Example

Two Dimensional Array

Imports System
Imports System.Collections.Generic
Imports System.Linq
Imports System.Text

Namespace TwoDimensionalArray
    Class Program
        Private Shared Sub Main(ByVal args As String())
            Dim a As Integer(,)
            Dim r, c As Integer
            Console.WriteLine("Enter row and columne values")
            r = Integer.Parse(Console.ReadLine())
            c = Integer.Parse(Console.ReadLine())
            a = New Integer(r - 1, c - 1) {}
            Console.WriteLine("Enter {0} X {1} values", r, c)

            For i As Integer = 0 To r - 1

                For j As Integer = 0 To c - 1
                    a(i, j) = Integer.Parse(Console.ReadLine())
                Next
            Next

            Console.WriteLine("The {0} X {1} Matrix is ", r, c)

            For i As Integer = 0 To r - 1

                For j As Integer = 0 To c - 1
                    Console.Write(a(i, j) & " ")
                Next

                Console.Write(vbLf)
            Next
        End Sub
    End Class
End Namespace


┬ęCopyright 2016 All Rights Reserved LearnDotNetHome.com