VB.NET tutorial: Arrays-Two-Dimensional Array


VB.NET Arrays

Two-Dimensional Array

Another frequently used array is two-dimensional array. A two-dimensional array stores values in rows and columns. The row index starts from 0. The column index also starts from 0. You will use the New keyword to allocate a two-dimensional array.



Index 


0


1


2


0

1

2

3


1

4

5

6

Example:


Module Module1
 
    Sub Main()
       'Declaring and allocating the 2D-array of 2 rows and 3 columns
        Dim arr(,) As Integer
        arr = New Integer(1, 2) {{1, 2, 3}, {4, 5, 6}}
        For i = 0 To arr.GetUpperBound(0) 'max row index
            For j = 0 To arr.GetUpperBound(1) 'max column index
                Console.Write(arr(i, j) & vbTab)
            Next
            Console.WriteLine()' print new line
        Next
        Console.ReadLine()
 
    End Sub
End Module


Comments

Lindo comment

 Lindo

Consider Table 2 below, with 5 rows and 7 columns, in which, each cell is either valid(V0 or invalid(I) Assume the values in a table 2are stored in a multi-dimension array write a function procedure, using the nested for….next statement to calculate the percentage of the valid cells in a Table

The formula to percentage of a valid cells is
(number of valid cells/ total number of cells) * 100

0 1 2 3 4 5 6
0 V I V I V V I
1 I I V I V V V
2 I V I V I I V
3 V V I V I I V
4 1 V I I V V I




2017-10-13
anand  comment

 anand

to help full..........................................


2017-04-01
islam comment

 islam

great v helpful......


2017-03-26
rafy comment

 rafy

nead listview


2017-03-15
CAPTCHA image




This website intents to provide free and high quality tutorials, examples, exercises and solutions, questions and answers of programming and scripting languages:
C, C++, C#, Java, VB.NET, Python, VBA,PHP & Mysql, SQL, JSP, ASP.NET,HTML, CSS, JQuery, JavaScript and other applications such as MS Excel, MS Access, and MS Word. However, we don't guarantee all things of the web are accurate. If you find any error, please report it then we will take actions to correct it as soon as possible.