Arrays
Arrays
Programming In
Visual Basic.NET
Arrays
• List or series of values all referenced by the
same name
• Similar to list of values for list boxes and
combo boxes - without the box
• Use an array to keep a series of variable for
later processing such as
– Reordering
– Calculating
– Printing
Dim ArrayName(UpperSubscript) as
Datatype
Dim ArrayName( ) as
Datatype = {InitialValueList}
mgiGroup array
(0) 101 0
(1) 103 0
(2) 110 10
(3) 115 0
(4) 121 0
(5) 123 0
(6) 130 0
(7) 145 0
intScoreBoard(0,0) intScoreBoard(1,0)
intScoreBoard(0,1) intScoreBoard(1,1)
intScoreBoard(0,2) intScoreBoard(1,2)
intScoreBoard(0,3) intScoreBoard(1,3)
intScoreBoard(0,4) intScoreBoard(1,4)
intScoreBoard(0,5) intScoreBoard(1,5)
Dim ArrayName(HighestSubscript,
Highest Subscript) as Datatype
Dim ArrayName( , ) as
Datatype = {ListOfValues}
decColTotal(5)
0 1 2 3 4 5
8- 37 © 2001 by The McGraw-Hill Companies, Inc. All rights reserved.
Summing Code Example
'Crossfoot Total a 2D table
Dim decAmount(3,5) As Decimal
Dim decRowTotal(3) As Decimal
Dim decColTotal(5) As Decimal
Dim intRowIndex As Integer
Dim intColIndex As Integer
For intRowIndex = 0 to 3
For intColIndex = 0 to 5
decRowTotal(intRowIndex) += decAmount(intRowIndex, intColIndex)
decColTotal(intColIndex) += decAmount(intRowIndex, intColIndex)
Next intColIndex
Next intRowIndex
Zone Subscript
of Array uses
lstZone.SelectedIndex