GNVQ Visual Basic & IT - Unit 6 (Sue Cahill)


An ARRAY is a convenient way of dealing with a set of values.  For example you may want to work on monthly income over a year.  Instead of having 12 variables Jan Feb ......etc. it would  be better to use a single array with 12 elements. This may be referred to as:

mnthIncome(0)
mnthIncome(1)
mnthIncome(2)
--------->.
mnthIncome(11)

(Note that an array starts to number from zero)

An Array may be declared as a static array (the upper and lower bands are known and once set cannot change) or a dynamic array where the upper and lower bands are not always known and can change during the running of the program.

To declare an array is similar to declaring an ordinary variable and in our case may be in the form:-

Dim mnthIncome (11) as integer

The number in parenthesis (brackets) is the upper band number.  Remember that the numbering starts at zero (0)
An alternatively the declaration can be more specific:-

Dim mnthIncome (0 to 11) as integer

The range does not have to start with the lower band at (0).


 Top of Page
Home Page
Query for Tutor?