Updated: July 20, 2015
For the latest documentation on Visual Studio 2017 RC, see Visual Studio 2017 RC Documentation.
Simulates the occurrence of an error.
Required. Can be any valid error number.
Error statement is supported for backward compatibility. In new code, especially when creating objects, use the
Raise method to generate run-time errors.
errornumber is defined, the
Error statement calls the error handler after the properties of the
Err object are assigned the following default values:
|Value specified as argument to |
|Name of the current Visual Basic project.|
|String expression corresponding to the return value of the |
|The fully qualified drive, path, and file name of the appropriate Visual Basic Help file.|
|The appropriate Visual Basic Help file context ID for the error corresponding to the |
If no error handler exists, or if none is enabled, an error message is created and displayed from the
Err object properties.
Some Visual Basic host applications cannot create objects. See your host application's documentation to determine whether it can create classes and objects.
This example uses the
Error statement to generate error number 11.
On Error Resume Next ' Defer error handling. Error 11 ' Simulate the "Division by zero" error.
Assembly: Visual Basic Runtime Library (in Microsoft.VisualBasic.dll)