Sub errorTest() Dim intNumerator As Integer Dim intDenominator As Integer Dim intResult As Integer
On Error GoTo mytrap
intNumerator = 1
intDenominator = 0
intResult = intNumerator / intDenominator
msgBox ("The result is " & intResult)
Exit Sub
mytrap:
msgBox "You cannot divide by zero" End Sub