Erl (function)

Syntax

Erl[()]

Description

Returns the line number of the most recent error.

Comments

The first line of the script is 1, the second line is 2, and so on.

The internal value of Erl is reset to 0 with any of the following statements: Resume, Exit Sub, Exit Function. Thus, if you want to use this value outside an error handler, you must assign it to a variable.

Example

This example generates an error and then determines the line on which the error occurred.

Sub Main()
  Dim i As Integer
  On Error Goto Trap1
  i = 32767       'Generate an error--overflow.
  i = i + 1
  Exit Sub
Trap1:
  MsgBox "Error on line: " & Erl
  Exit Sub         'Reset the error handler.
End Sub

See Also

Err (function); Error, Error$ (functions); Error Handling (topic).

More information

E