Text Documents (Writer)
HTML Documents (Writer Web)
Spreadsheets (Calc)
Presentations (Impress)
Drawings (Draw)
Database Functionality (Base)
Formulae (Math)
Charts and Diagrams
Macros and Scripting
Office Installation
Common Help Topics
OneOffice Logo

Err Function

Returns an error code that identifies the error that occurred during program execution.

Syntax:


Err

Return value:

Integer

Parameters:

The Err function is used in error-handling routines to determine the error and the corrective action.

Example:


Sub ExampleError
On Error Goto ErrorHandler REM Set up error handler
Dim iVar as Integer
Dim sVar As String
REM Error occurs due to non-existent file
    iVar = Freefile
    Open "\file9879.txt" for Input as #iVar
    Line Input #iVar, sVar
    Close #iVar
Exit Sub
ErrorHandler:
    MsgBox "Error " & Err & ": " & Error$ + chr(13) + "At line : " + Erl + chr(13) + Now, 16 ,"an error occurred"
End Sub