Visual Basic.NET Comprehensive Concepts and Techniques Chapter 8 Debugging, Creating Executable Files, and Distributing a Windows Application.

Slides:



Advertisements
Similar presentations
Office 2003 Post-Advanced Concepts and Techniques M i c r o s o f t Excel Project 7 Using Macros and Visual Basic for Applications (VBA) with Excel.
Advertisements

Using Macros and Visual Basic for Applications (VBA) with Excel
Office 2003 Introductory Concepts and Techniques M i c r o s o f t Excel Web Feature Creating Static and Dynamic Web Pages Using Excel.
Microsoft Office 2007 Excel Web Feature Creating Web Pages Using Excel.
Microsoft Office 2007 Excel Chapter 8 Formula Auditing, Data Validation, and Complex Problem Solving.
Microsoft Windows Vista Chapter 5 Personalize Your Work Environment.
Office 2003 Post-Advanced Concepts and Techniques M i c r o s o f t Word Project 7 Creating an Online Form.
Microsoft Office 2007 PowerPoint Web Feature Creating Web Pages Using PowerPoint.
Microsoft Office 2010 Access Chapter 1 Creating and Using a Database.
Office 2003 Introductory Concepts and Techniques M i c r o s o f t Word Project 2 Creating a Research Paper.
The IDE (Integrated Development Environment) provides a DEBUGGER for locating and correcting errors in program logic (logic errors not syntax errors) The.
Office 2003 Introductory Concepts and Techniques M i c r o s o f t Access Project 1 Creating and Using a Database.
Chapter 2: The Visual Studio.NET Development Environment Visual Basic.NET Programming: From Problem Analysis to Program Design.
Office 2003 Post-Advanced Concepts and Techniques M i c r o s o f t Word Project 8 Working with Macros and Visual Basic for Applications (VBA)
Office 2003 Advanced Concepts and Techniques M i c r o s o f t Outlook Project 2 Scheduling Management and Instant Messaging Using Outlook.
COMPREHENSIVE Excel Tutorial 8 Developing an Excel Application.
Access Tutorial 10 Automating Tasks with Macros
Microsoft Visual Basic 2010: Reloaded Fourth Edition Chapter One An Introduction to Visual Basic 2010.
Microsoft Visual Basic 2012 CHAPTER TWO Program and Graphical User Interface Design.
Microsoft Visual Basic 2005 CHAPTER 8 Using Procedures and Exception Handling.
CHAPTER SIX Loop Structures.
Microsoft Visual Basic 2005 CHAPTER 12 Cell Phone Applications and Web Services.
CHAPTER 6 Loop Structures.
Microsoft Visual Basic 2012 CHAPTER TWELVE (ENRICHMENT CHAPTER) Windows Store Apps.
CHAPTER SIX.
Microsoft Office 2007 Access 2007 Chapter 9 Administering a Database System.
Microsoft Visual Basic 2012 Using Procedures and Exception Handling CHAPTER SEVEN.
Microsoft Visual Basic 2005 CHAPTER 5 Mobile Applications Using Decision Structures.
Project 1: Creating a Dreamweaver Web Page and Local Site 1 Project Objectives Add a background image Open and close panels Display and describe the Property.
 What are the different types of loops? ◦ Do….While  Performs statements within loop while a condition is true ◦ Do….Until  Performs statements within.
Debugging Projects Using C++.NET Click with the mouse button to control the flow of the presentation.
Microsoft Windows Vista Chapter 1 Fundamentals of Using Microsoft Windows Vista.
Automating Database Processing Chapter 6. Chapter Introduction Design and implement user-friendly menu – Called navigation form Macros – Automate repetitive.
Microsoft Windows 7 Part 1 Fundamentals of Using Windows 7.
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 2 The Visual Basic.NET Integrated Development Environment.
Office 2003 Advanced Concepts and Techniques M i c r o s o f t PowerPoint Collaboration Feature Delivering Presentations to and Collaborating with Workgroups.
Office 2003 Advanced Concepts and Techniques M i c r o s o f t Access Project 6 Switchboards, PivotTables, and PivotCharts.
Microsoft Visual Basic 2005 ENRICHMENT CHAPTER Visual Studio Tools for Office.
Office 2003 Introductory Concepts and Techniques M i c r o s o f t Word Project 1 Creating and Editing a Word Document.
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 7 Using Menus, Common Dialogs, Procedures, Functions, and Arrays.
Microsoft Office 2007 Access Chapter 6 Using Macros, Switchboards, PivotTables, and PivotCharts.
Chapter One An Introduction to Visual Basic 2010 Programming with Microsoft Visual Basic th Edition.
Program Design and Coding
Microsoft Visual Basic 2012 CHAPTER THREE Program Design and Coding.
Microsoft Visual Basic 2010 CHAPTER THREE Program Design and Coding.
Dreamweaver CS4 Concepts and Techniques Chapter 2 Adding Web Pages, Links, and Images.
Using Microsoft Visual Studio 2005 Original by Suma Rao Revised by John G. McMahon ( 9/6/2008 )
Office 2003 Post-Advanced Concepts and Techniques M i c r o s o f t Access Project 7 Advanced Report and Form Techniques.
Microsoft Access 2010 Chapter 10 Administering a Database System.
Microsoft Publisher 2010 Chapter 1 Creating a Flyer.
XP New Perspectives on Microsoft Office FrontPage 2003 Tutorial 7 1 Microsoft Office FrontPage 2003 Tutorial 7 – Creating and Using Templates in a Web.
Office 2003 Introductory Concepts and Techniques M i c r o s o f t Access Project 1 Creating and Using a Database.
Chapter 2 – Introduction to the Visual Studio .NET IDE
Debugging Visual Basic.NET Programs ► ► Use debugging tools ► ► Set breakpoints and correct mistakes. ► ► Use a Watch and Local window to examine variables.
Microsoft Office 2010 is the newest version of Microsoft Office, offering features that provide users with better functionality and easier ways to work.
Microsoft Visual Basic 2010 CHAPTER TWO Program and Graphical User Interface Design.
Object-Oriented Application Development Using VB.NET 1 Chapter 2 The Visual Studio.NET Development Environment.
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 3 Building an Application in the Visual Basic.NET Environment.
Microsoft Visual Basic 2012 CHAPTER FIVE Decision Structures.
IE 411/511: Visual Programming for Industrial Applications Lecture Notes #2 Introduction to the Visual Basic Express 2010 Integrated Development Environment.
 2002 Prentice Hall. All rights reserved. 1 Introduction to the Visual Studio.NET IDE Outline Introduction Visual Studio.NET Integrated Development Environment.
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 6 Looping and Multiple Forms.
Chapter 10 Using Macros, Controls and Visual Basic for Applications (VBA) with Excel Microsoft Excel 2013.
Chapter 2: The Visual Studio.NET Development Environment Visual Basic.NET Programming: From Problem Analysis to Program Design.
Office 2003 Introductory Concepts and Techniques M i c r o s o f t Access Project 1 Creating and Using a Database.
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 12 Creating Console Applications, Understanding XML, and Creating Web Services.
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 11 Creating Web Applications and Writing Data to a Database.
Excel Tutorial 8 Developing an Excel Application
Chapter 2: The Visual Studio .NET Development Environment
ME 142 Engineering Computation I
Presentation transcript:

Visual Basic.NET Comprehensive Concepts and Techniques Chapter 8 Debugging, Creating Executable Files, and Distributing a Windows Application

Chapter 8: Debugging, Creating Executable Files, and Distributing a Windows Application 2 Objectives Describe the difference between syntax, logic, and run-time errors Find syntax errors during design time Fund run-time errors and logic errors during run time Set breakpoints Execute one statement at a time by stepping

Chapter 8: Debugging, Creating Executable Files, and Distributing a Windows Application 3 Objectives Set the next statement to execute Evaluate variables using DataTips Evaluate variables and expressions using the QuickWatch and Watch windows Change values of variables using debug tools Use the Autos, Locals, and Me windows to examine variables and objects

Chapter 8: Debugging, Creating Executable Files, and Distributing a Windows Application 4 Objectives Use the Command window to execute commands Set the icon for an executable file Create an executable file Create a setup program to distribute a Windows application

Chapter 8: Debugging, Creating Executable Files, and Distributing a Windows Application 5

6 Starting Visual Basic.NET and Opening an Existing Project Insert the Data Disk in drive A Start Visual Basic.NET. When the Start Page appears, click the Open Project button Double-click the Chapter8 folder on the Data Disk Double-click the Today’s Sales Check folder. If necessary, click the Today’s Sales Check solution file Click the Open button

Chapter 8: Debugging, Creating Executable Files, and Distributing a Windows Application 7

8 Visual Basic.NET Error Types Syntax Errors –Code violates a rule of the Visual Basic.NET language Logic Errors –Code executes, but program results are incorrect Run-time Errors –Program halts during run-time due to an invalid statement or operation (divide by zero)

Chapter 8: Debugging, Creating Executable Files, and Distributing a Windows Application 9 Syntax Errors Occur when the code violates a rule of the Visual Basic.NET language –Misspelled keywords –Misspelled variable names –Missing keywords Visual Basic.NET underlines syntax errors, and Intellisense™ displays a description of the error when the mouse hovers over

Chapter 8: Debugging, Creating Executable Files, and Distributing a Windows Application 10 Finding and Fixing Syntax Errors Using the Task List Window Click View on the menu bar, select Other Windows, and click Task List Double-click the third task in the Task List Double-click the fourth task in the Task List Click line 169 and enter Dim sngTotalAdvertised As Single as the new line of code. After entering the code, click a different line to move the insertion point to another line of code Double-click the first task in the Task List window

Chapter 8: Debugging, Creating Executable Files, and Distributing a Windows Application 11 Finding and Fixing Syntax Errors Using the Task List Window Right-click the word, Check in line 148 on the left side of the assignment statement Click the ListMembers command Double-click the property, Checked, in the Members list. Click another line in the code window Double-click the value, Fales, on line 148. Type False to correct the spelling mistake. Click another line in the code window

Chapter 8: Debugging, Creating Executable Files, and Distributing a Windows Application 12 Using Breakpoints with Stepping and DataTips Click the Start button on the Visual Basic.NET Standard toolbar Click the Close button in the Today’s Sales Check window to close the window. Click the Today’s Sales Form.vb tab in the main work area Scroll to the frmTodaysSalesCheck_Resize event procedure. Click the column at the left side of the code window, directly to the left of line 213

Chapter 8: Debugging, Creating Executable Files, and Distributing a Windows Application 13

Chapter 8: Debugging, Creating Executable Files, and Distributing a Windows Application 14 Using Stepping and DataTips with Breakpoints With a breakpoint set at line 213, click the Start button on the Standard toolbar to enter run time. When the execution halts at line 213, click the Breakpoints tab Move the mouse pointer over the property, Me.Width, on line 213. Move your mouse pointer over intColumn0Width on line 213 DataTip displays with the property or variable name, along with their current value Press the F8 key to step through the statements

Chapter 8: Debugging, Creating Executable Files, and Distributing a Windows Application 15 Disabling a Breakpoint and Correcting a Logic Error Right-click anywhere in line 213. When the code window shortcut menu appears, click the Disable Breakpoint command Click the Stop Debugging button on the Debug toolbar. Use the code window scroll bar to scroll the code window to the right, until the end of line 213 displays. Click after the text, lstTodaysSales.Columns(2).Width. Enter - lstTodaysSales.Columns(3).Width and then press the SPACEBAR

Chapter 8: Debugging, Creating Executable Files, and Distributing a Windows Application 16

Chapter 8: Debugging, Creating Executable Files, and Distributing a Windows Application 17

Chapter 8: Debugging, Creating Executable Files, and Distributing a Windows Application 18 Breaking on a Run-Time Error and Using a QuickWatch Click the Start button on the Standard toolbar to run the project Click the Enter Today’s Sales button. Enter the test data in table 8-4 on page VB 8.26 Click the OK button after entering the second item, without entering a description in the Item Description text box Click the Total Today’s Sales button Click the Break button in the Microsoft Development Environment dialog box

Chapter 8: Debugging, Creating Executable Files, and Distributing a Windows Application 19 Breaking on a Run-Time Error and Using a QuickWatch Right-click the variable, intIndex, in line 174, the last line executed before the line that causes the error, to check the value of the variable prior to the error. When the code window shortcut menu appears, click the QuickWatch command Click the Close button in the QuickWatch window. Repeat the previous process with the intListCount variable in line 174 Click the Close button in the QuickWatch window

Chapter 8: Debugging, Creating Executable Files, and Distributing a Windows Application 20 Adding a Watch to the Watch Window With the application in break mode and paused on line 175, right-click the intIndex variable on line 174. When the code window shortcut menu appears, click the Add Watch command Repeat the process above with the lstTodaysSales.Items(intIndex).SubItems( 1).Text property on line 175, and the intListCount variable on line 174.

Chapter 8: Debugging, Creating Executable Files, and Distributing a Windows Application 21 Adding a Watch to the Watch Window Click the Stop Debugging button on the Debug toolbar Click to the left of line 175 to set a breakpoint at line 175

Chapter 8: Debugging, Creating Executable Files, and Distributing a Windows Application 22 Watching Variables and Using a Breakpoint in a Loop Click the Start button on the Standard toolbar Click the Enter Today’s Sales button. Enter the test data in table 8-4 on page VB 8.26 and click the OK button after entering the second item, without entering a description in the Item Description text box Click the Total Today’s Sales button

Chapter 8: Debugging, Creating Executable Files, and Distributing a Windows Application 23 Watching Variables and Using a Breakpoint in a Loop Press the F5 key to resume running the project Press the F5 key (again) to resume running the project Click the Stop Debugging button on the Debug toolbar

Chapter 8: Debugging, Creating Executable Files, and Distributing a Windows Application 24 Fixing a Run-Time Error in a For…Next Loop Click the end of line 174. Type – 1 to fix the error Right-click line 175. When the code window shortcut menu displays, click the Disable Breakpoint command

Chapter 8: Debugging, Creating Executable Files, and Distributing a Windows Application 25 Using the Autos Window Click the Start button on the Standard toolbar Click the Enter Today’s Sales button. Enter the test data in table 8-4 on page VB 8.26 and click the OK button after entering the second item, without entering a description in the Item Description text box Click the Total Today’s Sales button to determine if the application displays the expected results in the Daily Sales Totals message box

Chapter 8: Debugging, Creating Executable Files, and Distributing a Windows Application 26 Using the Autos Window Click the breakpoint status check box in the Breakpoints window to enable the breakpoint on line 175 Click the Today’s Sales Check application button on the Windows taskbar. When the Today’s Sales Check window displays, click the OK button in the Daily Sales Totals message box. Click the Total Today’s Sales button. When VB.NET enters break mode, press the F8 key eight times Click the Autos tab at the bottom of the IDE

Chapter 8: Debugging, Creating Executable Files, and Distributing a Windows Application 27 Fixing a Logic Error Click the Stop Debugging button on the Debug toolbar Change the index of the SubItems item in line 185 from the value, 2, to the value, 3 Right-click anywhere in line 175 and then click Disable Breakpoint on the code window shortcut menu

Chapter 8: Debugging, Creating Executable Files, and Distributing a Windows Application 28 Using the Locals Window to Evaluate Variables Click the Start button on the Standard toolbar Click the Enter Today’s Sales button. Enter the test data in table 8-4 on page VB 8.26 and click the OK button after entering the second item, without entering a description in the Item Description text box Click the Total Today’s Sales button to determine if the application displays the expected results in the Daily Sales Totals message box

Chapter 8: Debugging, Creating Executable Files, and Distributing a Windows Application 29 Using the Locals Window to Evaluate Variables Click the breakpoint status check box in the Breakpoints window to enable the breakpoint on line 175 Click the Today’s Sales Check application button in the Windows taskbar. When the Today’s Sales Check window appears, click the OK button in the Daily Sales Totals message box. Click the Total Today’s Sales button, and click the Locals tab at the bottom of the IDE Scroll the variable list in the Locals window until the intListCount variable displays. Press F8 nine times

Chapter 8: Debugging, Creating Executable Files, and Distributing a Windows Application 30 Fixing an Assignment Logic Error Click the Stop Debugging button on the Debug toolbar Select the variable, sngTotalAdvertised, on the right side of the assignment statement in line 186. Type sngItemSales to replace the variable, sngTotalAdvertised Right-click anywhere in line 175 and then click Disable Breakpoint on the code window shortcut menu Test and save the project, using the test data on page VB 8.26 in table 8-4

Chapter 8: Debugging, Creating Executable Files, and Distributing a Windows Application 31 Using the Command Window – Entering Commands Right-click the filled red circle icon to the left of line 175 and then click Disable Breakpoint. Click the empty red circle icon to the left of line 213 to enable the breakpoint at line 213, and press F5 to enter run time Click the Debug menu and point to the Windows command. Click the Immediate command on the Windows submenu At the insertion point in the Command window, type ?intColumn0Width and then press the ENTER key

Chapter 8: Debugging, Creating Executable Files, and Distributing a Windows Application 32 Using the Command Window – Entering Commands Press the F8 key to execute line 213. Type ?intColumn0Width in the Command window and then press the ENTER key Type >cmd in the Command window and then press the ENTER key Enter Debug.sto in the Command window, as shown in figure 8-54 on page VB 8.53 Click the Debug.StopDebugging command in the Intellisense™ list and then press the ENTER key

Chapter 8: Debugging, Creating Executable Files, and Distributing a Windows Application 33 Creating an Executable File Click the Today’s Sales Check project in the Solution Explorer window. Click the Property Pages icon on the Properties toolbar in the Properties window. When the Today’s Sales Check Property Pages appear, click the Build item in the Command Properties folder Click the Application icon ellipsis button. Select the CHECKMRK.ICO file located in the same folder as the project file, and click Open Click the Configuration Properties folder Click the OK button

Chapter 8: Debugging, Creating Executable Files, and Distributing a Windows Application 34 Creating an Executable File Click the Solution Configurations box arrow on the Standard toolbar. Select Release in the Solution Configurations list. Click Build on the menu bar Click the Build Solution command on the Build menu Open Windows Explorer and navigate to the folder, A:\Chapter8\Today’s Sales Check\Today’s Sales Check\bin Click the Windows Explorer Close button. In the VB.NET IDE, click File on the menu bar and then click Close Solution

Chapter 8: Debugging, Creating Executable Files, and Distributing a Windows Application 35

Chapter 8: Debugging, Creating Executable Files, and Distributing a Windows Application 36 Creating a Setup Project and Adding an Executable File With the Today’s Sales Check solution closed, click Project on the New submenu of the File menu. When the New Project dialog box appears, select Setup and Deployment Projects in the Project types box. Enter Today’s Sales Check Setup in the Name text box and then click the Setup Project icon in the Templates box

Chapter 8: Debugging, Creating Executable Files, and Distributing a Windows Application 37 Creating a Setup Project and Adding an Executable File Click the OK button. After VB.NET creates the new project, right-click the Application Folder folder in the File System window. When the shortcut menu appears, point to the Add command Click the File command on the Add submenu. When the Add Files dialog box appears, navigate to A:\Chapter8\Today’s Sales Check\Today’s Sales Check\bin and select the executable file (with the checkmark icon) Click the Open button

Chapter 8: Debugging, Creating Executable Files, and Distributing a Windows Application 38 Creating a Startup Menu Shortcut Right-click the User’s Programs Menu folder in the Folders window. Click the Add command on the User’s Programs Menu shortcut menu Click the Folder command. When the new folder displays in the Folders window, type Todays Sales Check as the folder name and then press the ENTER key Right-click anywhere in the Files window

Chapter 8: Debugging, Creating Executable Files, and Distributing a Windows Application 39 Creating a Startup Menu Shortcut Click the Create New Shortcut command. When the Select Item in Project dialog box appears, double-click the Application Folder folder Click the OK button. In the Files window, type Todays Sales Check as the name for the shortcut Click the Icon property value in the Properties window. Click the Icon property box arrow and then click Browse in the Icon property values list

Chapter 8: Debugging, Creating Executable Files, and Distributing a Windows Application 40 Creating a Startup Menu Shortcut When the icon dialog box appears, click the Browse button. When the Select Item in Project dialog box appears, double-click the Application Folder folder Select Executable Files (*.exe) in the Files of type list. Click the Todays Sales Check.exe file and then click the OK button Click the OK button in the Icon dialog box

Chapter 8: Debugging, Creating Executable Files, and Distributing a Windows Application 41

Chapter 8: Debugging, Creating Executable Files, and Distributing a Windows Application 42 Setting Options and Building a Setup Program Click the Todays Sales Check Setup project in the Solution Explorer window. Then, click the Property Pages button in the Properties window When the Property Pages window appears, click the Bootstrapper box arrow Click None in the Bootstrapper list. Click the OK button

Chapter 8: Debugging, Creating Executable Files, and Distributing a Windows Application 43 Setting Options and Building a Setup Program When the Property Pages window closes, click the Build Solution command on the Build menu When the Output window indicates that the build is complete, close Visual Basic.NET

Chapter 8: Debugging, Creating Executable Files, and Distributing a Windows Application 44 Testing a Setup Program Open Windows Explorer and navigate to the folder, A:\Chapter8\Todays Sales Check Setup\Todays Sales Check Setup\Debug Double-click the Todays Sales Check Setup Windows Installer Package icon Click the Next button in the three subsequent dialog boxes

Chapter 8: Debugging, Creating Executable Files, and Distributing a Windows Application 45 Testing a Setup Program When the Todays Sales Check Setup dialog box displays the Installation Complete message, click the Close button Click the Start button on the taskbar and then point to All Programs on the Start menu. When the All Programs submenu appears, point to the Todays Sales Check command

Chapter 8: Debugging, Creating Executable Files, and Distributing a Windows Application 46

Chapter 8: Debugging, Creating Executable Files, and Distributing a Windows Application 47 Summary Describe the difference between syntax, logic, and run-time errors Find syntax errors during design time Fund run-time errors and logic errors during run time Set breakpoints Execute one statement at a time by stepping

Chapter 8: Debugging, Creating Executable Files, and Distributing a Windows Application 48 Summary Set the next statement to execute Evaluate variables using DataTips Evaluate variables and expressions using the QuickWatch and Watch windows Change values of variables using debug tools Use the Autos, Locals, and Me windows to examine variables and objects

Chapter 8: Debugging, Creating Executable Files, and Distributing a Windows Application 49 Summary Use the Command window to execute commands Set the icon for an executable file Create an executable file Create a setup program to distribute a Windows application

Visual Basic.NET Comprehensive Concepts and Techniques Chapter 8 Complete