Returns the script code line number where the most recent run-time error occured.
Erl() |
Use the Erl function to determine the line number of the source code where a run-time error occured. Usually it may be needed for debugging in an error handler defined by the On Error statement.
Sub ErlFuncDemo() On Error GoTo ErrorHandler ' Enable error-handling routine. Open "TESTFILE" For Output As #1 ' Open file for output. Kill "TESTFILE" ' Attempt to delete open file. Dim d As Double d = 10 / sin(0) ' "Division by zero" error d = 20 / cos(0) Trace d Exit Sub ' Exit to avoid handler. ErrorHandler: ' Error-handling routine. errNumber = Err() ' Get error number errLine = Erl() ' Get source code line Trace "ErrorNumber " & errNumber & " at line " & errLine Select Case errNumber ' Evaluate error number. Case 55, 75 ' "File already open" or "Path/File access error" error. Trace """File already open"" or ""Path/File access error"" error" Close #1 ' Close open file. Case Else ' Handle other situations here... Resume Next End Select Resume ' Resume execution at same line that caused the error. End Sub |
See Also |
Err Function , Error$ Function , On Error Statement , Trappable Errors |