SiteMap  | About    

Multi dimensional String Array

An array allows to refer related values by the same name and to use a number, called an index or subscript, to tell them apart. The individual values are called the elements of the array.

An array that uses more than one index or subscript is called multidimensional. A dimension is a direction in which you can vary the specification of an arrays elements.

Some arrays have two dimensions, therefore, such an array uses two indexes. The following example declares a variable to hold a two-dimensional array of office counts, for buildings 0 through 40 and floors 0 through 5.

The following VB.NET program shows a simple example of how to insert values in a two dimensional array and retrieve the values from two dimensional array.

Public Class Form1
	Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

		Dim i, j As Integer
		Dim strArr(1, 2) As String

		strArr(0, 0) = "First (0,0)"
		strArr(0, 1) = "Second (0,1)"

		strArr(1, 0) = "Third (1,0)"
		strArr(1, 1) = "Fourth (1,1)"

		For i = 0 To strArr.GetUpperBound(0)
			For j = 0 To strArr.GetUpperBound(0)
				MsgBox(strArr(i, j))

	End Sub
End Class (C) 2019    Founded by raps mk
All Rights Reserved. All other trademarks are property of their respective owners.