Returns the error message corresponding to a given error number (String).

errornumber(Optional) The error number of the text you want to return (Integer).

* The error message that is returned, corresponds to the Err.Description property.
* If "errornumber" is an error number that is not defined, then "Application-defined or object-defined error." is returned.
* If "errornumber" is not a number, then a run-time error is displayed.
* If "errornumber" is left blank, then the message corresponding to the most recent run-time error is returned.
* If "errornumber" is left blank, and no run-time error has occurred, then a zero-length string ("") is returned.
* If "errornumber" = 0, then a zero length string ("") is returned.
* You can use the ERROR Statement to generate an error.
* You can use the ERROR$ function to return a String data type instead of a Variant data type.
* The equivalent .NET function is Microsoft.VisualBasic.Information.Err
* For the Microsoft documentation refer to

Dim sErrorMessage As String 
sErrorMessage = Error(6)

Debug.Print Error(6) ' Overflow
Debug.Print Error(11) ' Division by zero
Debug.Print Error(55) ' File already open
Debug.Print Error() ' Returns an empty string
Debug.Print Error(-100) ' Application-defined or object-defined error
Debug.Print Error("some text") ' Generates a Type Mismatch run-time error

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