Err.HelpFile (property)

Syntax

Err.HelpFile [= filename]

Description

Sets or retrieves the name of the help file associated with the error.

Comments

The Err.HelpFile property, together with the Err.HelpContents property, contain sufficient information to display help for the error.

When BasicScript generates an error, the Err.HelpContents property is set to 0 and the Err.HelpFile property is set to ""; the value of the Err.Number property is sufficient for displaying help in this case. The exception is with errors generated by an OLE automation server; both the Err.HelpFile and Err.HelpContext properties are set by the server to values appropriate for the generated error.

When generating your own user-define errors, you should set the Err.HelpContext property and the Err.HelpFile property appropriately for your error. If these are not set, then BasicScript displays its own help at an appropriate place.

Example

'This example defines a replacement for InputBox that deals

'specifically with Integer values. If an error occurs, the

'function generates a user-defined error that can be trapped

'by the caller.

Function InputInteger(Prompt,Optional Title,Optional Def)

On Error Resume Next

  Dim x As Integer

  x = InputBox(Prompt,Title,Def)

  If Err.Number Then

    Err.HelpFile ="AZ.HLP"

    Err.HelpContext = 2

    Err.Description = "Integer value expected"

    InputInteger = Null

    Err.Raise 3000

  End If

  InputInteger = x

End Function

Sub Main

  Dim x As Integer

  Do

  On Error Resume Next

  x = InputInteger("Enter a number:")

  If Err.Number = 3000 Then

    MsgBox "Invalid number, press ""F1"" to invoke help" _

    ,,, Err.HelpFile,Err.HelpContext

  End If

  Loop Until Err.Number <> 3000

End Sub

See Also

Error Handling (topic)m Err.Clear (method), Err.HelpContext (property), Err.Description ((property), Err.LastDLLError (property), Err.Number (property), Err.Source (property)

Note

The Err.HelpFile property can be set to any valid Windows help file (i.e., a file with a .HLP extension compatible with the WINHELP help engine).

More information

E