Erl Property | Microsoft.VisualBasic.Information |
Erl |
|
An Integer containing the line number
Indicates the line number on which an error occurred.
Err.Clear Method | Microsoft.VisualBasic.ErrObject |
Err.Clear( ) |
|
Explicitly resets all the properties of the Err object after an error has been handled.
Err.Description Property | Microsoft.VisualBasic.ErrObject |
Err.Description = string To set the property string = Err.Description To return the property value |
|
string required; String
Any string expression
A read/write property containing a short string describing a runtime error.
Err.GetException Method | Microsoft.VisualBasic.ErrObject |
Err.GetException( ) |
|
A System.Exception object or an object inherited from it containing the current exception
Returns the Exception object associated with the current error.
Err.HelpContext Property | Microsoft.VisualBasic.ErrObject |
Err.HelpContext |
|
A read/write property that either sets or returns an Integer value containing the context ID of the appropriate topic within a Help file.
Err.HelpFile Property | Microsoft.VisualBasic.ErrObject |
Err.HelpFile |
|
A read/write String property that contains the fully qualified path of a Windows Help file.
Err.LastDLLError Property | Microsoft.VisualBasic.ErrObject |
Err.LastDLLError |
|
A read-only property containing a system error code representing a system error produced within a DLL called from a VB program.
Err.Number Property | Microsoft.VisualBasic.ErrObject |
Err.Number |
|
A read/write property containing a numeric value that represents the error code for the last error generated.
Err.Raise Method | Microsoft.VisualBasic.ErrObject |
Err.Raise(number, source, description, helpfile, helpcontext) |
|
number required; Long integer
A numeric identifier of the particular error
source optional; String
The name of the object or application responsible for generating the error
description optional; String
A useful description of the error
helpfile optional; String
The fully qualified path of a Microsoft Windows Help file containing help or reference material about the error
helpcontext optional; Long
The context ID within helpfile
Generates a runtime error.
Err.Source Property | Microsoft.VisualBasic.ErrObject |
Err.Source |
|
A read/write string property containing the name of the application or the object that has generated the error.
ErrorToString Function | Microsoft.VisualBasic.Conversion |
ErrorToString([errornumber]) |
|
errornumber optional; Long
A numeric error code
A String containing an error message
Returns the error message or error description corresponding to a particular error code.
IsError Function | Microsoft.VisualBasic.Information |
IsError(expression) |
|
expression required; Object
An object variable that may be an Exception object
Boolean (True if expression is an Exception object, False otherwise)
Indicates whether an object is an instance of the Exception class or one of its derived classes.
On Error Statement |
|
On Error GoTo label|0|-1 Syntax 1. On Error Resume Next Syntax 2. |
|
label Either label, 0 , or -1 is required
A valid label within the subroutine
Enables or disables error handling within a procedure.
If you don't use an OnError statement or a Try...Catch block in your procedure, or if you have explicitly switched off error handling, the Visual Basic runtime engine will automatically handle the error. First, it will display a dialog box containing the standard text of the error message. Second, it will terminate the application. So any error that occurs in the procedure will produce a fatal runtime error.
Resume Statement |
|
Resume [0] Resume Next Resume label |
|
Used to continue program execution when an error-handling routine is complete.
Throw Statement |
|
Throw exception |
|
exception required; System Exception or a derived type
An Exception object representing the exception being thrown
Throws an exception that can be handled using either structured exception handling (a Try . . . Catch block) or unstructured exception handling (the On Error statement).
Try...Catch...Finally Statement |
|
Try tryStatements [Catch1 [exception [As type]] [When expression] catchStatements1 [Exit Try] Catch2 [exception [As type]] [When expression] catchStatements2 [Exit Try] ... Catchn [exception [As type]] [When expression] catchStatementsn] [Exit Try] [Finally finallyStatements] End Try |
|
exception optional; System.Exception or a derived type
The exception to catch. If exception is omitted or if it is System.Exception, all exceptions will be caught. However, if exception is omitted, no information about the exception will be accessible within the Catch block.
type optional
The data type of the exception to be handled by the Catch block. Its value can be System.Exception or any derived type. If omitted, its value defaults to System.Exception, and all exceptions will be handled.
expression optional; Boolean
A logical expression that defines a condition under which the error is to be handled by the Catch block.
Handles runtime errors using Structured Exception Handling.
The tryStatements, which are required, constitute the Try block and are the statements that VB monitors for errors.
The Catchblocks, of which there can be more than one, contain code that is executed in response to VB "catching" a particular type of error within the Try block. Thus, the Catch blocks consist of the error-handlers for the Try block.
The phrases exception[Astype] and [Whenexpression] are referred to as filters in the VB.NET documentation. In the former case, exception is either a variable of type Exception, which is the base class that "catches" all exceptions, or a variable of one of Exception's derived classes. The When filter is typically used with user-defined errors.
The ExitTry statement is used to break out of any portion of a Try...Catch...Finally block.
The optional finallyStatements code block is executed regardless of whether an error occurs (or is caught), unless an ExitTry statement is executed.
Multiple Catch statements can be used. However, only the first Catch statement to be true is executed. This means that multiple Catch statements should be ordered from most specific to most general, with a Catch block handling errors of type System.Exception occurring last.