© Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Outline 20.1 Test-Driving the Shipping Hub Application.

Slides:



Advertisements
Similar presentations
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Outline 24.1 Test-Driving the Ticket Information Application.
Advertisements

© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Tutorial 12 – Security Panel Application Introducing.
Microsoft Visual Basic: Reloaded Chapter Seven More on the Repetition Structure.
Objectives Understand the software development lifecycle Perform calculations Use decision structures Perform data validation Use logical operators Use.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Tutorial 21 - “Cat and Mouse” Painter Application.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Tutorial 16 – Craps Game Application Introducing Random-Number.
Microsoft Visual Basic: Reloaded Chapter Six Repeating Program Instructions.
Visual Basic 2010 How to Program. © by Pearson Education, Inc. All Rights Reserved.2.
Visual Basic 2010 How to Program Reference: Instructor: Maysoon Bin Duwais slides Visual Basic 2010 how to program by Deitel © by Pearson Education,
© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Tutorial 4 – Introducing Algorithms, Pseudocode and.
Excel and VBA Creating an Excel Application
Programming Based on Events
© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Tutorial 8 - Interest Calculator Application: Introducing.
© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Tutorial 12 – Craps Game Application: Introducing Random.
Liang, Introduction to Java Programming, Ninth Edition, (c) 2013 Pearson Education, Inc. All rights reserved. 1 Chapter 22 Lists, Stacks, Queues, and Priority.
© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Tutorial 6 – Car Payment Calculator Application: Introducing.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved. 1 9 Car Payment Calculator Application Introducing the Do While...Loop and Do Until...Loop.
Chapter 8: String Manipulation
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved Flag Quiz Application Introducing One-Dimensional Arrays and ComboBox es.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Outline 16.1 Test-Driving the Flag Quiz Application.
© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Tutorial 2 - Welcome Application: Introduction to C++
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Tutorial 26 – CheckWriter Application Introducing Graphics.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Introducing Web Controls Outline 29.1 Analyzing the.
Microsoft Visual Basic 2010: Reloaded Fourth Edition Chapter Six Repeating Program Instructions.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved Interest Calculator Application Introducing the For...Next Repetition Statements.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved Shipping Hub Application Introducing Generic Collections, LINQ, For Each...Next.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Tutorial 30 – Bookstore Application: Client Tier Introducing.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved Typing Application Introducing Keyboard Events, Menus, Dialogs and the Dictionary.
© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Tutorial 8 - Interest Calculator Application: Introducing.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Tutorial 30 – Bookstore Application: Client Tier Examining.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Outline 7.1 Test-Driving the Wage Calculator Application.
© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Tutorial 4 – Wage Calculator Application: Introducing.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Tutorial 27 - Phone Book Application Introducing Multimedia.
© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Tutorial 5 – Dental Payment Application: Introducing.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Chapter 13 – Graphical User Interfaces Part 2 Outline.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Outline 32.1 Reviewing the Bookstore Application 32.2.
© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Tutorial 9 – Income Tax Calculator Application: Introducing.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved Ticket Information Application Introducing Sequential-Access Files.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved. 1 3 Welcome Application Introduction to Visual Programming.
© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Tutorial 6 – Car Payment Calculator Application: Introducing.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Tutorial 17 – Flag Quiz Application Introducing One-Dimensional.
Tutorial 6 The Repetition Structure
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Outline 19.1 Test-Driving the Shipping Hub Application.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved Security Panel Application Introducing the Select Case Multiple-Selection Statement.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Outline 3.1 Test-Driving the Welcome Application 3.2.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved Screen Scraping Application Introducing String Processing.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved Class Average Application Introducing the Do...Loop While and Do...Loop Until.
© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Tutorial 7 – Class Average Application: Introducing.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Outline 21.1 Test-Driving the Painter Application.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Tutorial 21 - “Cat and Mouse” Painter Application.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Outline 2.1 Test-Driving the Welcome Application 2.2.
INSERT BOOK COVER 1Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall. Exploring Getting Started with VBA for Microsoft Office 2010 by.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Outline 25.1 Test-Driving the ATM Application 25.2.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Tutorial 18 – Student Grades Application Introducing.
Programming with Microsoft Visual Basic 2008 Fourth Edition Chapter Eight String Manipulation.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Outline 5.1 Test-Driving the Inventory Application.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Outline 8.1 Test-Driving the Car Payment Calculator.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Tutorial 15 – Fund Raiser Application Introducing.
© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Tutorial 3 – Inventory Application: Introducing Variables,
© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Tutorial 3 – Inventory Application: Introducing Variables,
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Outline 10.1 Test-Driving the Interest Calculator.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved. 1 4 Designing the Inventory Application Introducing TextBox es and Button s.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Outline 5.1 Test-Driving the Enhanced Inventory Application.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved Student Grades Application Introducing Two-Dimensional Arrays and RadioButton.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved Address Book Application Introducing Database Programming.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Tutorial 16 – Craps Game Application Introducing Random-Number.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Outline 17.1 Test-Driving the Student Grades Application.
 2003 Prentice Hall, Inc. All rights reserved. 1 Outline 11.1 Test-Driving the Interest Calculator Application 11.2 Essentials of Counter-Controlled Repetition.
Tutorial 10 – Class Average Application Introducing the Do…Loop While and Do…Loop Until Repetition Statements Outline Test-Driving the Class Average.
Tutorial 12 – Security Panel Application Introducing the Select Case Multiple-Selection Statement Outline Test-Driving the Security Panel Application.
Presentation transcript:

© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Outline 20.1 Test-Driving the Shipping Hub Application 20.2 Package Class 20.3 Using Properties TabIndex and TabStop 20.4 Using Access Keys 20.5 Collections 20.6 Shipping Hub Application: Using Class ArrayList 20.7 foreach Repetition Statement 20.8 Wrap-Up Tutorial 20 – Shipping Hub Application Introducing Collections, the foreach Statement and Access Keys

© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 2 Objectives In this tutorial, you will learn to: –Create and manipulate an ArrayList object. –Set the TabStop and TabIndex properties of a control. –Create an access key for a control. –Use a foreach loop to iterate through an ArrayList.

© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Test-Driving the Shipping Hub Application

© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Test-Driving the Shipping Hub Application Figure 20.1 Shipping Hub application when first run. Run the Shipping Hub application – Debug > Start

© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Test-Driving the Shipping Hub Application Figure 20.2 Scanning a new package. Click Scan New Button Click in Address: TextBox and type 318 Some Street

© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Test-Driving the Shipping Hub Application Figure 20.3 Pressing the Tab key moves the cursor to the next TextBox. Cursor now appears in the City : TextBox

© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Test-Driving the Shipping Hub Application Figure 20.4 Viewing all packages going to South Carolina. You can view all Package ID’s by state using the ComboBox

© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Package Class

© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Package Class Figure 20.6 Solution Explorer with Package.cs added. Package class added to the ShippingHub project

© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Using Properties TabIndex and TabStop TabIndex and access keys – Requires only the keyboard (allows user to avoid constantly switching between using the mouse and keyboard).

© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Using Properties TabIndex and TabStop Figure 20.7 Setting the TabIndex properties using the Tab Order view of the Shipping Hub application. TabIndex boxes (not modified) TabIndex box set to zero Set TabStop property to true for controls that receive user input and false for the other controls

© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Using Properties TabIndex and TabStop Figure 20.8 Tab Order view of the Shipping Hub application. Set the TabIndex properties by clicking each control in the order indicated

© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Using Access Keys Figure 20.9 Creating an access key. Using the & symbol to create an access key (there is no space between & and S ) Access key letter underlined

© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Collections Collections –Used to store groups of related objects –Aid in storage and organization of data, requiring no knowledge of how they work. ArrayList –Dynamic resizing capability Grow and shrink according to storage needs –Contained in Collections namespace

© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Shipping Hub Application:Using Class ArrayList

© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Shipping Hub Application:Using Class ArrayList

© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Shipping Hub Application:Using Class ArrayList

© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Shipping Hub Application:Using Class ArrayList Figure Declaring the ArrayList reference. Declaring an ArrayList reference Accessing ArrayList – Use the member-access operator (. ) OR – Member of System.Collections namespace

© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Shipping Hub Application:Using Class ArrayList Figure Creating an ArrayList object. Creating the ArrayList reference

© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Shipping Hub Application:Using Class ArrayList Figure Creating a Package object. Create a new Package object with a unique ID

© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Shipping Hub Application:Using Class ArrayList Figure Displaying the package’s number and arrival time. Displaying arrival time and package ID number in Label s ToString method returns value representing object as a string – Example: 11/11/2002 9:34:00 AM

© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Shipping Hub Application:Using Class ArrayList Figure Adding a package to the ArrayList. Adding a Package object to an ArrayList An Object’s position in ArrayList is called an index – Index of first object is zero

© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Shipping Hub Application:Using Class ArrayList Figure Removing a package from the ArrayList. Removing the current package from the ArrayList

© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Shipping Hub Application:Using Class ArrayList Figure Changing the Edit Button to display Update. Using code to change the text displayed on a Button

© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Shipping Hub Application:Using Class ArrayList Figure Removing and inserting a package to update data. Updating the ArrayList with new package information

© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Shipping Hub Application:Using Class ArrayList Figure Setting the Button ’s Text property back to Edit. Using code to display the text on the Button

© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Shipping Hub Application:Using Class ArrayList Figure Retrieving a package from the ArrayList. Retrieving a Package object from an ArrayList

© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Shipping Hub Application:Using Class ArrayList Figure Displaying the package data in the Form ’s controls. Displaying data stored in the Package object

© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved foreach Repetition Statement foreach ( Package objPackage in objArrayList ) { lstPackages.Items.Add( objPackage.PackageNumber ); } The foreach statement requires both a collection type and an element – Collection type : specifies the array or collection through which you wish to iterate – Element : Use to store a reference to a value in the collection type

© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved foreach Repetition Statement Figure UML activity diagram for foreach repetition statement.

© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved foreach Repetition Statement Figure Writing a foreach statement. foreach header

© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved foreach Repetition Statement Figure Displaying all packages going to selected state. Displaying package ID numbers only for packages destined for the specified state

Outline © Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 33 ShippingHub.cs (1 of 15)

Outline © Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 34 ShippingHub.cs (2 of 15)

Outline © Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 35 ShippingHub.cs (3 of 15)

Outline © Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 36 ShippingHub.cs (4 of 15)

Outline © Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 37 ShippingHub.cs (5 of 15) Use a Random object to generate a random number for package IDs Initially, there are no objects in the ArrayList so set the position to zero

Outline © Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 38 ShippingHub.cs (6 of 15)

Outline © Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 39 ShippingHub.cs (7 of 15) Display package ID numbers in ListBox if the state names match

Outline © Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 40 ShippingHub.cs (8 of 15) When the user clicks the NEXT > Button, increment the position. If the position was the last object in the array, set the position to zero When the user clicks the < BACK Button, decrement the position. If the position was zero, set the position to the last object in the ArrayList

Outline © Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 41 ShippingHub.cs (9 of 15) Load the next package, update m_intPosition as necessary

Outline © Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 42 ShippingHub.cs (10 of 15)

Outline © Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 43 ShippingHub.cs (11 of 15)

Outline © Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 44 ShippingHub.cs (12 of 15) Retrieve data from user, and store it in the Package object

Outline © Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 45 ShippingHub.cs (13 of 15) Enable or disable Buttons depending on value of blnState

Outline © Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 46 ShippingHub.cs (14 of 15) Defining the SelectedIndexChanged event of a ComboBox

Outline © Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 47 ShippingHub.cs (15 of 15)