debugging visual basic.net programs ► ► use debugging tools ► ► set breakpoints and correct...

13
Debugging Visual Basic .NET Programs Use debugging tools Set breakpoints and correct mistakes. Use a Watch and Local window to examine variables during program execution.

Upload: damon-thomas

Post on 04-Jan-2016

213 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Debugging Visual Basic.NET Programs ► ► Use debugging tools ► ► Set breakpoints and correct mistakes. ► ► Use a Watch and Local window to examine variables

Debugging Visual Basic

.NET Programs

► Use debugging tools ► Set breakpoints and correct mistakes.► Use a Watch and Local window to examine variables during program execution.

Page 2: Debugging Visual Basic.NET Programs ► ► Use debugging tools ► ► Set breakpoints and correct mistakes. ► ► Use a Watch and Local window to examine variables

Logic error exampleLogic error example

If Age > 13 And Age < 20 ThenTextBox2.Text = “You’re a teenager”ElseTextBox2.Text = “You’re not a teenager”End If

A teenager is a person who is between 13 and 19 years old

Page 3: Debugging Visual Basic.NET Programs ► ► Use debugging tools ► ► Set breakpoints and correct mistakes. ► ► Use a Watch and Local window to examine variables

The structure fails to identify the person who is exactly 13

Page 4: Debugging Visual Basic.NET Programs ► ► Use debugging tools ► ► Set breakpoints and correct mistakes. ► ► Use a Watch and Local window to examine variables

Debug Tool BarDebug Tool Bar

►Break mode gives you a close-up look at your program while the Visual Basic compiler is executing it.

Break AllBreak All

StartStart

StopStop

Step IntoStep Into

Step OutStep Out

Step OverStep OverRun To CursorRun To Cursor

BreakpointsBreakpointsLocalsLocals

Watch1Watch1

Page 5: Debugging Visual Basic.NET Programs ► ► Use debugging tools ► ► Set breakpoints and correct mistakes. ► ► Use a Watch and Local window to examine variables

BreakpointBreakpoint

►You can set a breakpoint by clicking You can set a breakpoint by clicking the gray margin to the left of the line the gray margin to the left of the line of code shown.of code shown.

Breakpoint

Gray margin

Page 6: Debugging Visual Basic.NET Programs ► ► Use debugging tools ► ► Set breakpoints and correct mistakes. ► ► Use a Watch and Local window to examine variables

Debug ToolbarDebug Toolbar

►Step Into Step Into You can step through your code line by You can step through your code line by

line.line. This includes stepping into any function or This includes stepping into any function or

procedure that the code callsprocedure that the code calls ..

►Step OverStep Over Works in a similar way to Step Into, but Works in a similar way to Step Into, but

you pass straight over the procedures and you pass straight over the procedures and functionfunction

Page 7: Debugging Visual Basic.NET Programs ► ► Use debugging tools ► ► Set breakpoints and correct mistakes. ► ► Use a Watch and Local window to examine variables

Debug ToolbarDebug Toolbar

►Step Out Step Out This allows you to jump to the end of the This allows you to jump to the end of the

procedure or function that you are procedure or function that you are currently in currently in

Move to the line of code after the line that Move to the line of code after the line that called the procedure or function.called the procedure or function.

This is handy when you step into a long This is handy when you step into a long procedure and want to get out of it.procedure and want to get out of it.

Page 8: Debugging Visual Basic.NET Programs ► ► Use debugging tools ► ► Set breakpoints and correct mistakes. ► ► Use a Watch and Local window to examine variables

Debug ToolbarDebug Toolbar

►Run To CursorRun To Cursor Enable you to place your cursor anywhere Enable you to place your cursor anywhere

in the code following the current in the code following the current breakpoint.breakpoint.

The code between the current breakpoint The code between the current breakpoint where the cursor is positioned will be where the cursor is positioned will be executedexecuted

The execution will stop on the line of code The execution will stop on the line of code where the cursor is located.where the cursor is located.

Page 9: Debugging Visual Basic.NET Programs ► ► Use debugging tools ► ► Set breakpoints and correct mistakes. ► ► Use a Watch and Local window to examine variables

Working With BreakpointWorking With Breakpoint

► To view the Data Tip hover the mouse To view the Data Tip hover the mouse over the variable.over the variable.

►You can change the contents of the You can change the contents of the variable by clicking the variable name variable by clicking the variable name then change the text box value.then change the text box value.

Page 10: Debugging Visual Basic.NET Programs ► ► Use debugging tools ► ► Set breakpoints and correct mistakes. ► ► Use a Watch and Local window to examine variables

Watch WindowWatch Window

► It is provides a method for you to watch It is provides a method for you to watch variable and expressions easily while variable and expressions easily while the code is executing.the code is executing.

►You can add and delete only when your You can add and delete only when your program is in break mode.program is in break mode.

► It is allow to change the value of a It is allow to change the value of a variable.variable. The text for the value turn to The text for the value turn to redred..

►You need to set a breakpoint You need to set a breakpoint beforebefore the variable that you want to watchthe variable that you want to watch

Page 11: Debugging Visual Basic.NET Programs ► ► Use debugging tools ► ► Set breakpoints and correct mistakes. ► ► Use a Watch and Local window to examine variables

Watch WindowWatch Window

►Step 2Step 2

Page 12: Debugging Visual Basic.NET Programs ► ► Use debugging tools ► ► Set breakpoints and correct mistakes. ► ► Use a Watch and Local window to examine variables

Watch WindowWatch Window

►Step 3Step 3

Page 13: Debugging Visual Basic.NET Programs ► ► Use debugging tools ► ► Set breakpoints and correct mistakes. ► ► Use a Watch and Local window to examine variables

Local WindowLocal Window

► It is similar to the Watch window.It is similar to the Watch window.► It shows all variables and objects for It shows all variables and objects for

the current function or procedure.the current function or procedure.