Professional Documents
Culture Documents
17
Flag Quiz Application
Introducing one-dimensional arrays
and comboboxes
2
Objectives
Introducing Arrays
Declaring Arrays
■ Before you can use an array, you must specify its size
and allocate memory for it
my_array = New Integer (0 To 12) {}
Declaring Arrays
■ Initialize the array
Dim my_array As Integer ()
my_array = New Integer () {10, 50, 60, 40}
Declaring Arrays
■ It can also be written as
Dim my_array() As Integer= {10, 50, 60, 40}
9
Error-Prevention Tip
•Use Methd GetUpperBound when you need to find an
array’s highest index. Using an actual numerical value
for the upper bound instead could lead to errors if you
change the number of array elements
Determining whether a
country’s flag has been
displayed previosly
■ Informing the user that the quiz is over when five flags
have been displayed
■ Sorting an array
Alphabetizing country
names in the array