Chapter 71 Arrays Creating and Accessing Arrays Using Arrays Some Additional Types of Arrays.

Slides:



Advertisements
Similar presentations
Etter/Ingber Arrays and Matrices. Etter/Ingber One-Dimensional Arrays 4 An array is an indexed data structure 4 All variables stored in an array are of.
Advertisements

1.
Microsoft Visual Basic 2010: Reloaded Fourth Edition
 “Regular” variable ◦ Holds a single value ◦ For example Dim Student1 as String Dim Student2 as String Dim Student3 as String … Dim Studentn as String.
Introduction to Computing Dr. Nadeem A Khan. Lecture 9.
VBA Modules, Functions, Variables, and Constants
Introduction to Computing Dr. Nadeem A Khan. Lecture 27.
Arrays-Part 1. Objectives Declare and initialize a one-dimensional array Store data in a one-dimensional array Display the contents of a one-dimensional.
Microsoft Visual Basic 2005: Reloaded Second Edition Chapter 8 Arrays.
Introduction to Computing Dr. Nadeem A Khan. Lecture 24.
Chapter 71 Array Properties Upper Bound: The value of arrayName.GetUpperBound(0) is the upper bound of arrayName(). Then What is the Lower Bound ? Ans:
Chapter 7 - Visual Basic Schneider1 Chapter 7 Arrays.
1 Chapter 7 Arrays. 2 Outline and Objective In this chapter we will Learn about arrays One-dimensional arrays Two-dimensional arrays Learn about searching.
Chapter 7 - Visual Basic Schneider1 Chapter 7 Arrays.
Chapter 71 Using Part of an Array Sometimes we do not know how many elements will be needed in an array. We can declare a large array, say of 100 elements,
Arrays Array of Controls: several controls, of the same type (Class: a prototype for an object indicating the properties and methods), that have the same.
1 Chapter 7 Arrays. 2 Outline and Objective In this chapter we will –Learn about arrays One-dimensional arrays Two-dimensional arrays –Learn about searching.
ISAT 252 Introduction to Arrays. Should have read 2 Chapter 8 –pp , and pp
A DMINISTRATIVE Midterm 1. A DMINISTRATIVE Assignment #3 Console Application Writing to the console Console.WriteLine(“Writing to the console”) UserInput.
IE 212: Computational Methods for Industrial Engineering
Visual Basic 2010 How to Program © by Pearson Education, Inc. All Rights Reserved.
Microsoft Visual Basic 2008 CHAPTER NINE Using Arrays and File Handling.
Microsoft Visual Basic 2005 CHAPTER 9 Using Arrays and File Handling.
Using Arrays and File Handling
1 Chapter 7 – Arrays 7.1 Creating and Accessing Arrays 7.2 Using LINQ with Arrays 7.3 Arrays of Structures 7.4 Two-Dimensional Arrays 7.5 A Case Study:
Arrays and 2D Arrays.  A Variable Array stores a set of variables that each have the same name and are all of the same type.  Member/Element – variable.
Arrays Part 9 dbg. Arrays An array is a fixed number of contiguous memory locations, all containing data of the same type, identified by one variable.
1 Chapter 7 – Arrays 7.1 Creating and Accessing Arrays 7.2 Using LINQ with Arrays 7.3 Arrays of Structures 7.4 Two-Dimensional Arrays 7.5 A Case Study:
1 Chapter 7 – Arrays 7.1 Creating and Using Arrays 7.4 Two-Dimensional Arrays.
Chapter 7 – Arrays 7.1 Creating and Accessing Arrays
Chapter 7 - VB 2008 by Schneider1 Chapter 7 – Arrays 7.1 Creating and Accessing Arrays 7.2 Using Arrays 7.3 Some Additional Types of Arrays 7.4 Sorting.
1 Chapter 7 – Arrays 7.1 Creating and Accessing Arrays 7.2 Using Arrays 7.3 Some Additional Types of Arrays 7.4 Sorting and Searching 7.5 Two-Dimensional.
1 Week 6 The Repetition Structure. 2 The Repetition Structure (Looping) Lesson A Objectives After completing this lesson, you will be able to:  Code.
Arrays Chapter 8. Chapter 8 - Part 12 Variable and Variable Array Variable Stores only one value Variable Array Variable that has 1 symbolic name but.
Tutorial 6 The Repetition Structure
Arrays. Variable Arrays a group of variables that have the same name and data type each element in a variable array is identified by a subscript refer.
Arrays. Overview u General Discussion  Uses  Structure  Declaration u Searching u Control Arrays.
CSC 162 Visual Basic I Programming. Array Parameters and Sorting Array Parameters –Entire Arrays –Individual Elements Sorting –Bubble Sort.
Computer Programming TCP1224 Chapter 11 Arrays. Objectives Using Arrays Declare and initialize a one-dimensional array Manipulate a one-dimensional array.
1 Working with Data Structures Kashef Mughal. 2 Chapter 5  Please review on your own  A few terms .NET Framework - programming model  CLR (Common.
1 Chapter 7 – Arrays 7.1 Creating and Accessing Arrays 7.2 Using LINQ with Arrays 7.3 Arrays of Structures 7.4 Two-Dimensional Arrays 7.5 A Case Study:
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter Arrays, Timers, and More 8.
Tutorial 101 Variable Arrays A group of variables that have the same name and data type and are related in some way Can have as many as 60 dimensions.
Chapter 9 Processing Lists with Arrays. Class 9: Arrays Understand the concept of random numbers and how to generate random numbers Describe the similarities.
Created by Alia Al-Abdulkarim 2008 Visual Basic Vs. Java.
Arrays Chapter 8. Overview u General discussion u Variable arrays u Control arrays u Multi-dimensional variable arrays  Two-dimensional  Three-dimensional.
Visual Basic 2010 How to Program © by Pearson Education, Inc. All Rights Reserved. - Edited By: Maysoon Al-Duwais 1.
Programming with Microsoft Visual Basic 2012 Chapter 9: Arrays.
Chapter 7 - VB.Net by Schneider1 Chapter 7 – Arrays 7.1 Creating and Accessing Arrays 7.2 Using Arrays 7.3 Control Arrays Skip Structures (7.3), 7.4 and.
CHAPTER EIGHT ARRAYS © Prepared By: Razif Razali1.
Chapter 7 - VB.Net by Schneider1 Chapter 7 – Arrays 7.1 Creating and Accessing Arrays 7.2 Using Arrays 7.3 Some Additional Types of Arrays 7.4 Sorting.
1 Chapter 7 Arrays. 2 Outline and Objective In this chapter we will Learn about arrays One-dimensional arrays Two-dimensional arrays Learn about searching.
Chapter81 For....Next Loops n For i = m To n statement (s) Next i n For statement designates a numeric variable, called control variable. n It is initialized.
Visual Basic Review LBS 126. VB programming Project Form 1Form 2Form 3 Text boxButton Picture box Objects Text box Button Objects.
Visual Basic CDA College Paphos Campus COM123 Visual Programming 1 Lecture: Charalambous Sotiris Week 8: COM123 Visual Programming 1 Lecture: Charalambous.
Ch. 101 DataTable (Continue) Lab sheet 10.3: Form Display Cities table along with percentage growth.
Chapter 7 - VB 2005 by Schneider1 Chapter 7 – Arrays 7.1 Creating and Accessing Arrays 7.1 (a) Arrays and Loops 7.2 Using Arrays 7.3 Some Additional Types.
Introduction to programming in java Lecture 21 Arrays – Part 1.
1 Chapter 7 – Arrays 7.1 Creating and Using Arrays 7.2 Using LINQ with Arrays 7.3 Arrays of Structures 7.4 Two-Dimensional Arrays.
Arrays 1.
Introduction to Computing Dr. Nadeem A Khan. Lecture 24.
Chapter 7 Arrays.
2. Understanding VB Variables
ARRAYS.
Visual Basic 2010 How to Program
Arrays.
CIS16 Application Development and Programming using Visual Basic.net
Chapter 7 - VB.Net by Schneider
Introduction to Computer Programming IT-104
Presentation transcript:

Chapter 71 Arrays Creating and Accessing Arrays Using Arrays Some Additional Types of Arrays

Chapter 72 Variable vs Array

Chapter 73 Simple and Array Variables A variable (or simple variable) is a name to which Visual Basic can assign a single value. An array variable is a collection of simple variables of the same type to which Visual Basic can efficiently assign a list of values.

Chapter 74 Creating and Accessing Arrays Declaring an Array Variable The Load Event Procedure The GetUpperBound Method ReDim Statement Using an Array as a Frequency Table

Chapter 75 Example Suppose that you want to evaluate the exam grades for 30 students and to display the names of the students whose scores are above average. Private Sub btnDisplay_Click(...) _ Handles btnDisplay.Click Dim student1 As String, score1 As Double Dim student2 As String, score2 As Double Dim student3 As String, score3 As Double

Chapter 76 It’s better when Using Arrays Dim student(29) As String Dim score(29) As Double Array name Upper bound of subscripts in the array Data type

Chapter 77 Putting Values into an Array student(0) = "Tom Brown" subscript Read: "student sub zero equals Tom Brown" Which means that the string "Tom Brown" is being stored at the first location in the array called student… because all arrays begin counting at 0.

Chapter 78 Array Terminology Dim arrayName(n) As DataType 0 is the "lower bound" of the array n is the "upper bound" of the array – the last available subscript in this array The number of elements, n + 1, is the size of the array

Chapter 79 Upper Bound & Lower Bound This is Upper Bond This is Lower Bond Number of elements in this array is

Chapter 710 Lab sheet 7.1: Form mtxtNumber txtWinner

Chapter 711 Example – Initialize the Array in the Button Private Sub btnWhoWon_Click(...) _ Handles btnWhoWon.Click Dim teamName(3) As String Dim n As Integer 'Place Super Bowl Winners into the array teamName(0) = "Packers" teamName(1) = "Packers" teamName(2) = "Jets" teamName(3) = "Chiefs" 'Access array n = CInt(txtNumber.Text) txtWinner.Text = teamName(n - 1) End Sub

Chapter 712 Lab sheet 7.1: Early Super Bowls

Chapter 713 Load Event Procedure Occurs as the Form loads in memory Private Sub frmName_Load(...) _ Handles MyBase.Load The keyword MyBase refers to the form being loaded. This event procedure is a good place to assign values to an array.

Chapter 714 Example- Initialize the Array in Form Load Dim teamName(3) As String Private Sub btnWhoWon_Click(...) Handles btnWhoWon.Click Dim n As Integer n = CInt(txtNumber.Text) txtWinner.Text = teamName(n - 1) End Sub Private Sub frmBowl_Load(...) Handles MyBase.Load 'Place Super Bowl Winners into the array teamName(0) = "Packers" teamName(1) = "Packers" teamName(2) = "Jets" teamName(3) = "Chiefs" End Sub

Chapter 715 Initializing Arrays when they are being created Arrays may be initialized when they are created: Dim arrayName() As varType = {value0, _ value1, value2,..., valueN} declares an array having upper bound N and assigns value0 to arrayName(0), value1 to arrayName(1),..., and valueN to arrayName(N).