Presentation is loading. Please wait.

Presentation is loading. Please wait.

Visual Basic .NET BASICS

Similar presentations


Presentation on theme: "Visual Basic .NET BASICS"— Presentation transcript:

1 Visual Basic .NET BASICS
Lesson 12 Arrays

2 Objectives Declare an array. Enter information into an array.
yo Objectives Declare an array. Enter information into an array. Access the information in an array. Use loops with arrays. Use parallel arrays.

3 Declaring and Accessing Arrays
An array allows you to refer to a series of variables by the same name and to use a number, called an index or subscript, to tell them apart.

4 Declaring Arrays Visual Basic .NET arrays are referred to as zero-based arrays because the index values start at zero. The number of values in the array must be declared. An array can also be declared with a list of initial values called an initialization list.

5 Accessing the Elements in an Array
The index, or subscript, is used to identify the element to be processed. However you specify the index, it must be a value between zero and the upper bound.

6 Array Methods and Properties
All arrays have a number of methods and properties that make using them easier. The Length property returns the number of elements in an array. The GetLowerBound and GetUpperBound methods return integers representing the lower and upper bounds of an array.

7 Using Loops with Arrays
There are several common ways that arrays and loops are used together. A loop can be used to apply the same process to each element in an array. A loop can be used to prompt for input for each element in an array and set its value. An array can be searched by using an If statement in a loop that compares each element of the array with a specific value.

8 Parallel Arrays Parallel arrays are arrays of the same length where each element in one array is related to an element in the second array with the same index value.

9 Summary Visual Basic. NET supports arrays that use an index or subscript to access different variables with the same name. All elements of an array are of the same data type. Arrays are declared by specifying the upper bound of the array.

10 Summary (continued) Arrays can be declared using initialization lists that set the starting values of the array. When arrays are declared using initialization lists, the upper bound is calculated by the system based on the number of items in the list. Individual elements in an array are read or changed by using an index value in paren-theses to identify the element to use.

11 Summary (continued) The GetLowerBound and GetUpperBound methods can be used to check that an index value is in the allowable range. The Length method of an array returns the number of elements in an array. Arrays can be processed sequentially using a loop. Parallel arrays are any number of arrays, which may be of different data types, that hold information in corresponding elements.


Download ppt "Visual Basic .NET BASICS"

Similar presentations


Ads by Google