Review Questions


What type of errors is Visual Basic .NET good at catching?


Visual Basic .NET is superb at catching syntax errors. Indeed, it catches most of them the instant you press the Enter key to complete a statement.


What type of errors is Visual Basic .NET less adept at detecting?


Semantic errors are more difficult to detect because they can occur even though the code is syntactically correct. Logic errors are also difficult, if not impossible , for Visual Basic .NET to detect because the rules of the language are being obeyed, but the logic is flawed.


What is a breakpoint and how is it used?


A breakpoint is a debugging tool that lets you pause program execution at a certain line in the program. You create a breakpoint by placing the cursor on the line where you want to set the breakpoint and press the F9 key. This is the breakpoint line.


How does a breakpoint help you detect program bugs ?


Because a breakpoint pauses program execution but does not terminate it, all variables maintain their current values. You can use the various debug windows to inspect these variables to see which variables have values that are different from what you expect at the breakpoint. It is these unexpected values that serve as clues to detecting, isolating, and ultimately correcting the program error.


Can you explain what single-stepping a program means?


Single-stepping a program means executing the program one line at a time. You can single-step a program by pressing the F10 key once a breakpoint is reached. Often, you set a breakpoint at a place where you think the program error takes place. Obviously, the best place to place a breakpoint is on the line before the statement that causes the error. However, in the early stages of debugging an error, it's difficult to know precisely where the bug is. Therefore, when the program stops at the breakpoint, and you've inspected the values and they still look correct, you can single-step the program and observe what happens to the variables along the way.


What does stepping over a function mean in terms of debugging a program?


While you are single-stepping a program, if a statement calls a function that you wrote for the program, control jumps to the function code and resumes single-stepping in the function. However, in many cases, you don't want to enter the code associated with the function. You want to skip over the call to the function and resume single-stepping the program after the function call. This process of bypassing the single-stepping in the function is called stepping over a function. When program execution reaches a statement line with a function call, pressing the Shift+F10 keys causes the program to step over that function call.


What does stepping out of a function mean?


If you're single-stepping the code in a procedure and decide you want to skip the rest of the code, you can step out of the function by pressing the Ctrl+Shift+F10 keys. This causes program control to exit from the procedure and resume on the same statement line that initially called the procedure.


What is the difference between the Locals and Autos debug windows?


The Locals window shows you all the variables that have local scope. The Autos window shows you all the variables that are being used in the current statement line as well as the statement line before it. Also, the Locals window includes the Me object, which the Autos window does not. The Autos window is a good choice when there are a large number of local variables, but you want to concentrate on those variables being used in the current program statement.


What is the hit counter feature of the debugger?


The hit counter feature enables you to set a breakpoint that's activated only after the breakpoint statement line has been executed a specified number of times. For example, if you want to inspect the value of a certain variable after 50 iterations through a loop, you can set the hit counter to 49 and single-step from that point to the next iteration. This is much more efficient than pressing the F5 key 49 times. You can set the hit counter using the New Breakpoint dialog box (Ctrl+B).


What is a conditional breakpoint?


A conditional breakpoint enables you to type in an expression for a breakpoint that is triggered when the conditional expression evaluates to logic True. You can set the hit counter using the New Breakpoint dialog box (Ctrl+B).


What purpose does the Command window serve with respect to debugging?


You can use the Command window to set values for program variables as the program executes. This enables you to set certain test values at runtime rather than hard coding them into the program at design time.


What is unstructured error handling?


Unstructured error handling is the way all error processing was performed in all earlier versions of Visual Basic. The error processing was triggered using an On Error Goto labelname statement to activate an error trap. The label served as a branch point where program control was sent if an error condition was detected . Unstructured error trapping is less effective than structured error trapping, but is presented because there is a lot of legacy code that uses unstructured error handling.


What statements are associated with structured error processing?


The core of structured error processing is a Try - Catch statement block of the following general form:

 Try  TryStatementBlock  Catch [  parameter  ]  CatchStatementBlock  [Finally]  FinallyStatementBlock  End Try 

The TryStatementBlock contains the program statements that are processed during normal program execution. The CatchStatementBlock are the statements that are to be executed if an error occurs while the TryStatementBlock statements are being executed. The optional FinallyStatementBlock contains statements that are always to be executed. These are often cleanup statements that must be executed regardless of whether or not an error occurred.

Visual Basic .NET. Primer Plus
Visual Basic .NET Primer Plus
ISBN: 0672324857
EAN: 2147483647
Year: 2003
Pages: 238
Authors: Jack Purdum

Similar book on Amazon © 2008-2017.
If you may any questions please contact us: