Create an error, and then query the object for the error number and description
Sub errorTest0()
Dim intNumerator As Integer
Dim intDenominator As Integer
Dim intResult As Double
On Error GoTo mytrap
intNumerator = InputBox("Please enter a numerator", "Numerator")
enterDenominator:
intDenominator = InputBox("Please enter a denominator", "Denominator")
intResult = intNumerator / intDenominator
msgBox "The result is " & intResult
Exit Sub
mytrap:
msgBox "The number of this error is " & Err.number
msgBox "The description of the error is " & Err.Description
Resume enterDenominator
End Sub
Related examples in the same category