HelpContext, HelpFile, Source Properties (Err)

Purpose

Return or set the help properties for the Err object.

Syntax

Err.HelpContext [ = long ]

Err.HelpFile [ = string ]

Err.Source [ = string ]

Description

The HelpContext, HelpFile, and Source properties are set in conjunction with the Raise method. The Raise method allows you to create and generate user-defined errors for your application. When the application error is described in a help file, the context ID and the name of the file can be specified in these properties or as parameters in the Raise method.

If you are calling an older WinHlp32 (.hlp) help file, then the MsgBox statement is particularly useful to present the error information to the end user and if you a calling a newer HTMLHelp file type, a different message box structure detailed here can perform the same task. Alternatively, you can create your own display or message box using the Dialog object.

The Source property returns or sets a string specifying the name of the object or application that originally generated the error. For GFA-BASIC 32 runtime errors it is "GFA-BASIC 32", for OLE Automation errors it is the COM program name. When generating an error from code, Source is your application’s program name.

Example

You can use the following code to launch a message box:

Try

Err.Raise 1, "Quick Example", "This is a manufactured error", "HelpFilepath", 25

Catch

~MsgBox(Err.Description & #13#10#13#10 & "Help File: " & Err.HelpFile & #13#10 & "Help Context:" & Err.HelpContext, MB_OK, Err.Source)

EndCatch

Remarks

The Source property specifies a string expression representing the object that generated the error; the expression is usually the object's class name, program name, or programmatic ID. Use Source to provide information when your code is unable to handle an error generated in an accessed object. For example, if you access Microsoft Excel and it generates a Division by zero error, Microsoft Excel sets Err.Number to its error code for that error and sets Source to Excel.Application.

See Also

Err object, Raise, Err$

{Created by Sjouke Hamstra; Last updated: 17/07/2015 by James Gaite}