HelpContext Property (Visual Basic)

Applies To

Err Object.

Description

Returns or sets a context ID for a topic in a Microsoft Windows Help file.

Syntax

object.HelpContext [= ContextID]

The HelpContext property syntax has these parts:

Part

Description

object

Always the Err object.

ContextID

A valid identifier for a Help topic within the Help file.


Remarks

If a Microsoft Windows Help file is specified in HelpFile, the HelpContext property is used to automatically display the Help topic it identifies. If both HelpFile and HelpContext are empty, the value of Number is checked, and, if it corresponds to a Visual Basic run-time error value, then the Visual Basic Help context ID for the error is used. If the Number value does not correspond to a Visual Basic error, the contents screen for the Visual Basic Help file is displayed.

Note You should write routines in your application to handle typical errors. When programming with an object, you can use the Help supplied by the object’s Help file to improve the quality of your error handling, or to display a meaningful message to your user if the error is not recoverable. When writing OLE Automation objects, you should tailor your Help to programmers programming with your object, as well as supply meaningful information to an end user for an unrecoverable error. Not all Visual Basic host applications can create OLE Automation objects. See your host application’s documentation to determine whether it can create classes and OLE Automation objects.

See Also

Description Property, Err Object, HelpFile Property (Visual Basic), LastDLLError Property, Number Property, Source Property.

Example

This example uses the HelpContext property of the Err object to show the Visual Basic Help topic for the error Overflow.


Err.ClearError Resume Next.Raise 6                 ' Generate "Overflow" error.Err.Number <> 0 Then
    Msg = "Press F1 or Help to see " & Err.HelpFile & " topic for" & _
        " the following HelpContext: " & Err.HelpContext
    MsgBox Msg, , "Error: " & Err.Description, Err.HelpFile, _
        Err.HelpContextIf