540 likes | 711 Views
Microsoft Visual Basic 2008: Reloaded, Third Edition. 2. Objectives. After studying this chapter, you should be able to:Declare and initialize a one-dimensional arrayStore data in a one-dimensional arrayDisplay the contents of a one-dimensional arrayCode a loop using the For Each?Next statement
E N D
1. Microsoft Visual Basic 2008: Reloaded Third Edition Chapter Nine
Arrays
2. Microsoft Visual Basic 2008: Reloaded, Third Edition 2 Objectives After studying this chapter, you should be able to:
Declare and initialize a one-dimensional array
Store data in a one-dimensional array
Display the contents of a one-dimensional array
Code a loop using the For Each…Next statement
Access an element in a one-dimensional array
Search a one-dimensional array
Compute the average of a one-dimensional array’s contents
3. Microsoft Visual Basic 2008: Reloaded, Third Edition 3 Objectives (continued) Find the highest entry in a one-dimensional array
Update the contents of a one-dimensional array
Sort a one-dimensional array
Create and manipulate parallel one-dimensional arrays
Create and initialize a two-dimensional array
Store data in a two-dimensional array
Search a two-dimensional array
4. Microsoft Visual Basic 2008: Reloaded, Third Edition 4 Using Arrays Simple variable (or scalar variable): a variable that is unrelated to any other variable in memory
Array:
A group of variables with the same name and data type that are related in some way
Used to temporarily store related data in memory
Increases the efficiency of a program
Commonly used arrays:
One-dimensional
Two-dimensional
5. Microsoft Visual Basic 2008: Reloaded, Third Edition 5 One-Dimensional Arrays One-dimensional array:
Can be viewed as a column of variables
Subscript:
A unique number that identifies each variable in a one-dimensional array
Starts at 0 for first element in the array
Use array name and subscript to refer to each individual variable in the array
6. Microsoft Visual Basic 2008: Reloaded, Third Edition 6 One-Dimensional Arrays (continued)