' Visual Basic 2008 9.0 .NET Examples - Array Initializers - Arrays : Module Example Sub Main() Dim indexFirstDimension As Integer Dim indexSecondDimension As Integer Dim indexThirdDimension As Integer ' Dim row() As Integer = {1, 2, 3, 4, 5, 6} For indexFirstDimension = 0 To 5 Console.Write(row(indexFirstDimension) & " ") Next Console.WriteLine() ' Dim matrix(,) As Integer = {{1, 2, 3, 4, 5, 6}, _ {7, 8, 9, 10, 11, 12}} ' (1) For indexFirstDimension = 0 To 1 For indexSecondDimension = 0 To 5 Console.Write(matrix(indexFirstDimension, _ indexSecondDimension) & " ") Next Next Console.WriteLine() ' Dim cube(,,) As Integer = {{{1, 2, 3}, _ {4, 5, 6}}, _ {{7, 8, 9}, _ {10, 11, 12}}, _ {{13, 14, 15}, _ {16, 17, 18}}, _ {{19, 20, 21}, _ {22, 23, 24}}} ' (2) For indexFirstDimension = 0 To 3 For indexSecondDimension = 0 To 1 For indexThirdDimension = 0 To 2 Console.Write(cube(indexFirstDimension, _ indexSecondDimension, _ indexThirdDimension) & " ") Next Next Next ' Console.ReadLine() End Sub End Module Module ExerciseSolution Sub Main() Dim symbols() As String = _ {"M", "CM", "D", "CD", "C", "XC", "L", "XL", "X", "IX", "V", "IV", "I"} Dim units() As Integer = _ {1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1} ' Dim value, index As Integer Do Do Console.WriteLine("Value ?") value = Console.ReadLine() Loop Until value < 4000 AndAlso value >= 0 For index = 0 To 12 Do While value >= units(index) Console.Write(symbols(index)) value -= units(index) Loop Next Console.WriteLine() Loop End Sub End Module ' Visit www.studyvb.com for more examples. Copyright 2003-2008 De Wolf.