| 1: || |
What type of errors is Visual Basic .NET good at catching?
| A1: || |
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.
| 2: || |
What type of errors is Visual Basic .NET less adept at detecting?
| A2: || |
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.
| 3: || |
What is a breakpoint and how is it used?
| A3: || |
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.
| 4: || |
How does a breakpoint help you detect program bugs ?
| A4: || |
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.
| 5: || |
Can you explain what single-stepping a program means?
| A5: || |
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.
| 6: || |
What does stepping over a function mean in terms of debugging a program?
| A6: || |
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.
| 7: || |
What does stepping out of a function mean?
| A7: || |
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.
| 8: || |
What is the difference between the Locals and Autos debug windows?
| A8: || |
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.
| 9: || |
What is the hit counter feature of the debugger?
| A9: || |
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).
| 10: || |
What is a conditional breakpoint?
| A10: || |
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).
| 11: || |
What purpose does the Command window serve with respect to debugging?
| A11: || |
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.
| 12: || |
What is unstructured error handling?
| A12: || |
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.
| 13: || |
What statements are associated with structured error processing?
| A13: || |
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.