Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


Presentation on theme: "Visual Basic.NET Comprehensive Concepts and Techniques Chapter 8 Debugging, Creating Executable Files, and Distributing a Windows Application."— Presentation transcript:

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

2 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

3 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

4 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

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

6 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

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

8 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)

9 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

10 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

11 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

12 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

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

14 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

15 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

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

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

18 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

19 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

20 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.

21 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

22 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

23 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

24 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

25 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

26 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

27 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

28 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

29 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

30 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

31 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

32 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

33 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

34 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

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

36 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

37 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

38 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

39 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

40 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

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

42 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

43 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

44 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

45 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

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

47 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

48 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

49 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

50 Visual Basic.NET Comprehensive Concepts and Techniques Chapter 8 Complete


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

Similar presentations


Ads by Google