Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter 7 What’s Wrong with It? (Syntax and Logic Errors) Clearly Visual Basic: Programming with Visual Basic 2010 2 nd Edition.

Similar presentations


Presentation on theme: "Chapter 7 What’s Wrong with It? (Syntax and Logic Errors) Clearly Visual Basic: Programming with Visual Basic 2010 2 nd Edition."— Presentation transcript:

1 Chapter 7 What’s Wrong with It? (Syntax and Logic Errors) Clearly Visual Basic: Programming with Visual Basic 2010 2 nd Edition

2 Objectives Clearly Visual Basic: Programming with Visual Basic 2010, 2 nd Edition 2 After studying Chapter 7, you should be able to: Locate syntax errors using the Error List window Locate a logic error by stepping through the code Locate logic errors using breakpoints Fix syntax and logic errors

3 There’s a Bug in my Soup! Clearly Visual Basic: Programming with Visual Basic 2010, 2 nd Edition 3 Downside to variables and named constants Their use requires additional lines of code Bug Error in a program’s code Debugging Process of locating and correcting any bugs in a program Program bugs Typically caused by either syntax errors or logic errors

4 Finding Syntax Errors Clearly Visual Basic: Programming with Visual Basic 2010, 2 nd Edition 4 Syntax error Occurs when you break one of the language’s rules Code Editor Detects most syntax errors as you enter instructions

5 Locating Logic Errors Clearly Visual Basic: Programming with Visual Basic 2010, 2 nd Edition 5 Logic error Can occur for a variety of reasons Difficult type of error to locate Cannot be detected by Code Editor

6 Locating Logic Errors (cont’d.) Clearly Visual Basic: Programming with Visual Basic 2010, 2nd Edition 6 Debug the Discount Calculator application Letter D at end of a value indicates value’s data type is Decimal

7 Clearly Visual Basic: Programming with Visual Basic 2010, 2 nd Edition 7 Figure 7-7 btnCalc control’s Click event procedure

8 Locating Logic Errors (cont’d.) Clearly Visual Basic: Programming with Visual Basic 2010, 2 nd Edition 8 Figure 7-8 Result of using the Debug menu’s Step Into option

9 Locating Logic Errors (cont’d.) Clearly Visual Basic: Programming with Visual Basic 2010, 2 nd Edition 9 Use a breakpoint to pause execution at a specific line in the code Debug the Hours Worked application.0 at end of a number indicates that number’s data type is Double

10 Clearly Visual Basic: Programming with Visual Basic 2010, 2 nd Edition 10 Figure 7-14 Breakpoint set in the procedure Figure 7-15 Result of the computer reaching the breakpoint

11 Summary Clearly Visual Basic: Programming with Visual Basic 2010, 2 nd Edition 11 Program errors (bugs) Caused by either syntax errors or logic errors Syntax errors in an application’s code Listed in Error List window when you start the application You can locate logic errors by stepping through the code To set a breakpoint Right-click desired line of code, point to Breakpoint, and click Insert Breakpoint

12 Summary (cont’d.) Clearly Visual Basic: Programming with Visual Basic 2010, 2 nd Edition 12 Letter D at the end of a value Indicates value’s data type is Decimal.0 at the end of a number Indicates that the number’s data type is Double Before viewing value stored in a control or variable: First consider the value you expect to find


Download ppt "Chapter 7 What’s Wrong with It? (Syntax and Logic Errors) Clearly Visual Basic: Programming with Visual Basic 2010 2 nd Edition."

Similar presentations


Ads by Google