23 Arrays - Arrays CEE 3804 Computer Applications for CEE...

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

View Full Document Right Arrow Icon
Arrays CEE 3804 Computer Applications for CEE
Background image of page 1

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

View Full DocumentRight Arrow Icon
Arrays Many applications involve working with groups of related quantities arranged in the from of a list or table The individual elements are related to one another Examples: Weather data Rainfall Wind speed Temperature Snowfall
Background image of page 2
Arrays We use subscripts in mathematics when working with groups of related items x 1 , x 2 , x 3 … x n x 1 refers to first item x 2 refers to second item An array is a collection of variables of the same type that are referenced by the same name Arrays provide a compact, flexible and systematic way to handle groups of related data.
Background image of page 3

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

View Full DocumentRight Arrow Icon
Arrays in Visual Basic An array in Visual Basic is a collection of two or more storage locations, called array elements, associated with the same variable name. The array subscript, which is the number placed in parentheses after the array name defines the position of the individual element within the list If x() is an array consisting of 6 items then th e individual elements of the array are x(0), x(1), x(2), x(3), x(4), x(5) All array subscripts begin with 0 unless we change this
Background image of page 4
Declaring Arrays There are three ways in which we can declare arrays: 1. Use Public in the declarations section of a module 2. Use DIM statements in the declaration section of a module 3. Use DIM in a procedure
Background image of page 5

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

View Full DocumentRight Arrow Icon
Declaring an Array Syntax Dim arrayName As type() arrayName is the name of the array type is the data type of all the elements of the array The parenthesis after the data type indicates that this is an array
Background image of page 6
The DIM statement accomplishes the following tasks: Establishes the name of the array
Background image of page 7

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

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

Page1 / 24

23 Arrays - Arrays CEE 3804 Computer Applications for CEE...

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

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