Err Object

You can use the Err object to obtain information about the error.
The Err object contains information about any run-time errors.
When a run time error occurs, the properties of the Err object are filled with information that uniquely identifies the error and contains information that can be used to handle the error.
Error handling relies on the value in the Number property of the Err object to determine the cause of the error.

NumberThe error number. If this is zero then no error has occurred.
DescriptionA short description of the error
SourceThe project name from the Properties dialog box.
HelpContextThe context ID for a particular error in a help file.
HelpFileA folder location and filename of the help file.
LastDllErrorA system error code produced by a call to a DLL or external library (ie an APi call)

Clear Method

The Err object properties are reset to a zero and zero-length strings after an Exit, Resume Next or Goto 0 statement.
The clear method can be used explicitly to reset the properties.

Note The VarType for vberror is 10


The Err object has global scope.
It is possible to pass in an ErrObject into a subroutine but the object will be reset to Empty if an On Error statement is executed.

   Exit Sub 
   Call Error_Handle(msModuleName, sSubroutineName, Err)
End Sub

SS - snippet copy from Error_Handle


When an Error occurs, Visual Basic sets a global error object "Err" which contains information about the error that has occurred

© 2022 Better Solutions Limited. All Rights Reserved. © 2022 Better Solutions Limited TopPrevNext