Slides - Chapter 7

Slides - Chapter 7 - Chapter7 Arrays 1 BMGT302...

Info iconThis preview shows pages 1–12. Sign up to view the full content.

View Full Document Right Arrow Icon
Chapter 7 Arrays BMGT 302 Business Application  Programming 1
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
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 Used to temporarily store related data in memory Increases the efficiency of a program Commonly used arrays: One-dimensional  Two-dimensional Arrays 2
Background image of page 2
One-Dimensional Arrays One-dimensional array : Can be viewed as a column of variables (Vector) The variables are stored in  consecutive memory locations Each variable in the array has the same name and data  type 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 3
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
 Illustration of the naming convention for the one-dimensional  sales   array 4
Background image of page 4
One-Dimensional Arrays (cont'd.) Element : an individual variable in the array When an array is declared: Must specify the data type, name, and highest subscript to  be used First element has a subscript of 0 The array will contain one element more than the highest  subscript because subscripts start at 0 5
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
How to declare a one-dimensional array 6
Background image of page 6
One-Dimensional Arrays (cont'd.) Each element in the array is initialized if no values are  provided String array elements are initialized to the keyword  Nothing Numeric array elements are initialized to 0 Boolean array elements are initialized to False Date array elements are initialized to 12:00 AM January 1,  0001 7
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
One-Dimensional Arrays (cont'd.) Populating the array : assigning initial values  to an array List the values in a comma-separated list enclosed in  curly braces ({}) After declaration, can use an  assignment  statement  to store a value in an array element Length  property: indicates number of elements GetUpperBound  method: returns the highest  subscript 8
Background image of page 8
 How to store  data in a one- dimensional  array 9
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
How to use a one-dimensional array’s  Length  property One-Dimensional Arrays (cont'd.) 10
Background image of page 10
How to use a one-dimensional array’s  GetUpperBound  method One-Dimensional Arrays (cont'd.) 11
Background image of page 11

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 12
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 11/21/2011 for the course BMGT 302 taught by Professor Huang during the Fall '11 term at Maryland.

Page1 / 52

Slides - Chapter 7 - Chapter7 Arrays 1 BMGT302...

This preview shows document pages 1 - 12. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online