Download - vbnet10
-
7/31/2019 vbnet10
1/12
Getting Started With Exception Handling &
Debugging & Help
-
7/31/2019 vbnet10
2/12
Exception
An exception is termed as an abnormal condition encountered by an
application during execution.
Exception handling
Is the process of providing an alternate path to be executed
when the application is unable to execute in the desired way.
-
7/31/2019 vbnet10
3/12
Divides an application into blocks of code that have the probability ofraising an error.
Uses the TryCatchFinally statement. Errors are filtered in the Catch block
Structured exception
Try
..statement that can cause exception..
Catch ex
..code which will execute if respective exception occur..
Finally
..code which will execute regardless exception occurrence ..
End Try
-
7/31/2019 vbnet10
4/12
Unstructured exception
Is done by placing an On Error statement in a block of
code.
Uses the On Error GoTo statement to pass the control to a
specific error handler when an error occurs.
Uses the On Error Resume Next statement to pass control to the
next executable statement when an error occurs. Uses the On Error GoTo 0 to disable an error handler
On Error GoTo Lerr
..statement that can cause exception..
Exit SubLerr:
..code which will execute if respective exception occur..
[Resume Next]
-
7/31/2019 vbnet10
5/12
User-defined exceptions
Can be created by deriving a class from the ApplicationExceptionclass.
Class UserExp
Inherits ApplicationException
Public Function GetErrorMessage() as String
Return Invalid opertaion ..
End Function
End Class
-
7/31/2019 vbnet10
6/12
Debugging
Tracing and rectifying an error is termed as debugging.
In order to assist you in debugging logical and run-time errors,
Visual Basic .NET provides extensive debugging tools. You can
access these tools by using:
Debug toolbar
Debug menu
-
7/31/2019 vbnet10
7/12
Debugging Cont..
In an application, by using the debugging tools, you can:
Start execution
Break execution
Stop execution
Step Into
Step OverStep Out
A B C A, B, C
-
7/31/2019 vbnet10
8/12
Debugging Windows
The following windows are used for debugging an application: Watch window Call Stack window The Output window
-
7/31/2019 vbnet10
9/12
Help Providing
We can create following type helps for an application
Context-sensitive help for an application
Pop-up help
Tool tips for a control
-
7/31/2019 vbnet10
10/12
Help Providing cont..
Context-sensitive help for an application
HTML help displays the help content from an HTML file.
When the user presses the F1 key at run time, the HTML page containing thehelp content is displayed.
By using HTML Help files, you can display online context-sensitive help to auser.
HTML Help Workshop is a tool for creating HTML Help files, which storethe help content in HTML format.
-
7/31/2019 vbnet10
11/12
Help Providing cont..
Pop-up help
Provides help through the Help button, also called the Whats This button,
present in an application to the right of the title bar.
Is most effective in modal dialog boxes.
-
7/31/2019 vbnet10
12/12
Help Providing cont..
Tool tips for a control
Is a brief help message for individual controls on a form.
Can be displayed by adding a ToolTip control to the form and enter thetext in the ToolTipText property of the control for which the tool tip is to
be displayed. The SetToolTip() method of the ToolTip control is used to set the tool tip
text for a control.