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

Slides:



Advertisements
Similar presentations
CHAPTER TWO Creating Simple Visual Basic.NET Windows Applications.
Advertisements

© by Pearson Education, Inc. All Rights Reserved.
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.
Chapter 2: The Visual Studio.NET Development Environment Visual Basic.NET Programming: From Problem Analysis to Program Design.
Copyright © 2012 Pearson Education, Inc. Chapter 2 Introduction to Visual C#
1 Introduction to the Visual Studio.NET IDE Powerpoint slides modified from Deitel & Deitel.
Creating a Console Application with Visual Studio
Chapter 1 Introduction to Programming and C# Programming in C#.NET © 2003 by The McGraw-Hill Companies, Inc. All rights reserved.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved. 1 6 Enhancing the Inventory Application Introducing Variables, Memory Concepts and.
05/09/ Introducing Visual Basic Sequence Programming.
Hello World In C++ and Microsoft Visual C++. Directions to begin a project 1. Go to All Programs 2. Open Visual Studio C++ 3. Click on New Project 4.
© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Tutorial 2 - Welcome Application: Introduction to C++
© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Tutorial 2 - HelloWorld Application: Introduction to.
© 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.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved Interest Calculator Application Introducing the For...Next Repetition Statements.
VISUAL C++ PROGRAMMING: CONCEPTS AND PROJECTS Chapter 1B Introduction (Tutorial)
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.
Chapter 3: Using GUI Objects and the Visual Studio IDE.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Tutorial 30 – Bookstore Application: Client Tier Examining.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved Enhancing the Wage Calculator Application Introducing Function Procedures and.
© 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.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved. 1 8 Dental Payment Application Introducing CheckBox es and Message Dialogs.
Chapter One An Introduction to Visual Basic 2010 Programming with Microsoft Visual Basic th Edition.
© 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. 1 3 Welcome Application Introduction to Visual Programming.
CHAPTER TWO Creating Simple Visual Basic.NET Windows Applications.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved. 1 5 Completing the Inventory Application Introducing Programming.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Tutorial 17 – Flag Quiz Application Introducing One-Dimensional.
Programming with Visual C++: Concepts and Projects Chapter 2B: Reading, Processing and Displaying Data (Tutorial)
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.
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 8 Debugging, Creating Executable Files, and Distributing a Windows Application.
Chapter 2 – Introduction to the Visual Studio .NET IDE
Visual Basic 2010 How to Program © by Pearson Education, Inc. All Rights Reserved. - edited by Maysoon Al-Duwais1.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Outline 20.1 Test-Driving the Shipping Hub Application.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Outline 2.1 Test-Driving the Welcome Application 2.2.
Introduction to Visual Basic Programming. Introduction Simple Program: Printing a Line of Text Another Simple Program: Adding Integers Memory Concepts.
Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design Second Edition by Tony Gaddis.
© 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.
© 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 Tutorial 2 – Welcome Application Introduction to Graphical.
Microsoft Visual Basic 2008: Reloaded Third Edition Chapter One An Introduction to Visual Basic 2008.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Tutorial 4 – Completing the Inventory Application.
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.
Copyright (c) 2003 by Prentice Hall Provided By: Qasim Al-ajmi Chapter 2 Introduction to Visual Basic Programming Visual Basic.NET.
Object-Oriented Application Development Using VB.NET 1 Chapter 2 The Visual Studio.NET Development Environment.
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.
Addison Wesley is an imprint of © 2011 Pearson Addison-Wesley. All rights reserved. Chapter 2 Creating Applications with Visual Basic.
 2002 Prentice Hall. All rights reserved. 1 Introduction to the Visual Studio.NET IDE Outline Introduction Visual Studio.NET Integrated Development Environment.
Microsoft Visual C# 2010 Fourth Edition Chapter 3 Using GUI Objects and the Visual Studio IDE.
Microsoft Visual Basic 2012: Reloaded Fifth Edition Chapter One An Introduction to Visual Basic 2012.
Chapter 4.  Variables – named memory location that stores a value.  Variables allows the use of meaningful names which makes the code easier to read.
Visual Basic 2010 How to Program © by Pearson Education, Inc. All Rights Reserved.
Chapter 2: The Visual Studio.NET Development Environment Visual Basic.NET Programming: From Problem Analysis to Program Design.
Chapter 2: The Visual Studio .NET Development Environment
Chapter 1: An Introduction to Visual Basic 2015
Variables and Arithmetic Operations
Tutorial 19 - Microwave Oven Application Building Your Own Classes and Objects Outline Test-Driving the Microwave Oven Application Designing.
CIS16 Application Development Programming with Visual Basic
Presentation transcript:

© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Outline 5.1 Test-Driving the Inventory Application 5.2 Introduction to C# Code 5.3 Inserting an Event Handler 5.4 Performing a Calculation and Displaying the Result 5.5 Using the Debugger: Syntax Errors 5.6 Wrap-Up Tutorial 5 – Completing the Inventory Application Introducing Programming

© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 2 Objectives In this tutorial, you will learn to: –Add an event handler for a Button control. –Insert code into an event handler. –Access a property’s value by using C# code. –Use the assignment and multiplication operators.

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

© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Test-Driving the Inventory Application Input data into application –Enter 3 in the Cartons per shipment: TextBox –Enter 15 in the Items per carton: TextBox Figure 5.1 Inventory application with quantities entered.

© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Test-Driving the Inventory Application Click the Calculate Total Button –Observe result of calculation in the descriptive Label Figure 5.2 Result of clicking the Calculate Total Button in the Inventory application. Result of calculation

© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Introduction to C# Code The Options dialog –Setting option for Visual Studio.NET environment

© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Introduction to C# Code Figure 5.3 Options dialog. Text Editor folder icon

© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Introduction to C# Code Adding line numbers –Select the Text Editor folder icon Select the General item –Place a check in the CheckBox next to Line Numbers

© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Introduction to C# Code Figure 5.4 General settings page for C# text editor. C# folder General item Line Numbers CheckBox (checked)

© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Introduction to C# Code Setting the tab –Change the Indenting option –Change the Tabs settings –Insert spaces for each tab

© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Introduction to C# Code Figure 5.5 Setting the Tabs options. Smart Indenting (selected) Tabs item Insert spaces (selected)

© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Introduction to C# Code Fonts and colors –Change color used to display code –Use Defaults Button resets values

© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Introduction to C# Code Figure 5.6 Examining the Fonts and Colors page. Fonts and Colors item Use Defaults Button

© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Introduction to C# Code Renaming the Form –Set Form ’s Name property to FrmInventory

© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Introduction to C# Code The code editor –Code view using directive –Allows access to classes within specified namespace Class declaration –class keyword –Identifier –Braces around class body –Case sensitivity C# keywords and identifiers are case sensitive –Main method

© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Introduction to C# Code Figure 5.7 IDE showing the uppermost portion of the code for the Inventory application. Inventory.cs tabbed window Class declaration Class is declared in the Inventory namespace Using FCL namespaces

© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Introduction to C# Code Figure 5.8 IDE showing the lowermost portion of the code for the Inventory application. Main method

© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Introduction to C# Code Generated code –Expanding the code –Outlined code

© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Introduction to C# Code Figure 5.9 Windows Form Designer generated code, when expanded. Expanded code

© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Introduction to C# Code Figure 5.10 Ellipses indicating outlined code. Outlined code

© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Introduction to C# Code Generated code for a control –Default properties –The result of changes from design view

© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Introduction to C# Code Figure 5.11 Code generated by the IDE for lblCartons (with the code setting the Text property highlighted). Click tab for design view Property values for lblCartons

© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Inserting an Event Handler Renaming the Form in code –In comments above class declaration –In Main method

© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Inserting an Event Handler Figure 5.12 Renaming the Form above the class declaration.

© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Inserting an Event Handler Figure 5.13 Renaming the Form in method Main and adding spacing.

© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Inserting an Event Handler Event handling –Visual Studio.NET automatically inserts event handler when controls are double clicked –Event handler naming convention

© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Inserting an Event Handler Figure 5.14 Event handler btnCalculate_Click before you add your code. Asterisks indicate unsaved changes to application Empty event handler

© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Inserting an Event Handler Examine the application –Closing an application using the close box Figure 5.15 Running application without functionality. Close box

© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Inserting an Event Handler Adding code to an event handler –Comments in code Comments appear in green Use double slash characters –Executable C# statement Ends with semicolon Accessing properties –Member access operator (. )

© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Inserting an Event Handler Figure 5.16 Adding code to the Calculate Total Button ’s event handler. Event handler Type this code

© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Inserting an Event Handler IntelliSense –Display entire class’ members and their purposes Assignment operator –Two operands –Right to left

© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Inserting an Event Handler Figure 5.17 IntelliSense activating while entering code. Selected member Intellisense Description of selected member

© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Inserting an Event Handler Run the application –Enter input and examine the result Figure 5.18 Running the application with an event handler. Result of clicking Calculate Total Button

© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Performing a Calculation and Displaying the Result Changing the event handler –Add comments –Break header over multiple lines –Multiplication operator Int32.Parse method –Call a method –Return a value Convert.ToString method

© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Performing a Calculation and Displaying the Result Figure 5.19 Using multiplication in the Inventory application. Modified Inventory application code

Outline © Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 36 Inventory.cs (1 of 4) Renaming the Form

Outline © Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 37 Inventory.cs (2 of 4)

Outline © Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 38 Inventory.cs (3 of 4) Renaming the Form Adding a comment to your code Adding an event handler to your code Adding a comment to your code

Outline © Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 39 Inventory.cs (4 of 4) Adding a comment to your code

© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Using the Debugger: Syntax Errors Output window –Shows result of compilation Figure 5.21 Results of successful build in the Output window.

© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Using the Debugger: Syntax Errors The Task List –Displays the build error Description of the error Line number corresponding to the error Figure 5.22 Task List lists syntax errors.

© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Using the Debugger: Syntax Errors Identifying syntax error –Real-time error checking –Errors are underlined by a red jagged line –Task List will display the errors

© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Using the Debugger: Syntax Errors Figure 5.23 IDE with syntax errors. Jagged red underline indicates syntax error

© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Using the Debugger: Syntax Errors Figure 5.24 Task List displaying the syntax error recognized in real time.

© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Using the Debugger: Syntax Errors Matching the syntax error in the code –Double click an error in the Task List to highlight the code with the syntax error

© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Using the Debugger: Syntax Errors Figure 5.25 Highlighting the portion of code where a syntax error occurs. Highlighted syntax error

© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Using the Debugger: Syntax Errors Identifying second syntax error –Build > Build Solution compiles code Syntax error not found in real time

© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Using the Debugger: Syntax Errors Figure 5.26 IDE with second syntax error. Jagged blue underline indicates compilation error Compilation error shown in task list