O'Reilly logo

VBScript in a Nutshell, 2nd Edition by Ron Petrusha, Matt Childs, Paul Lomax

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

Err.HelpContext Property

Data Type

Long

Description

A read/write property that either sets or returns a long integer value containing the context ID of the appropriate topic within a Help file.

Rules at a Glance

  • The HelpContext property can be set either directly or by supplying the fifth parameter (the helpcontext parameter) to the Err.Raise method.

  • HelpContext IDs are decided upon when writing and creating a Windows help file. Once the Help or HTML help file has been compiled, the IDs can’t be changed. Each ID points to a separate Help topic.

Example

On Error Resume Next
    
Dim i

i = 8
MsgBox (i / 0)
If Err.Number <> 0 Then
   Err.Description = "You are attempting to divide by zero."
   Err.Helpfile = "C:\Windows\help\CustomApp.CHM"
   Err.HelpContext = 1000000 + Err.Number
   MsgBox Err.Description, vbMsgBoxHelpButton, "Error", Err.HelpFile, _ 
          Err.HelpContext
End If

Programming Tips and Gotchas

  • You can display a topic from a help file by supplying values to the Err.HelpFile and Err.HelpContext properties, using the MsgBox function with the vbMsgBoxHelpButton constant and passing Err.HelpContext as the HelpContext argument (as shown in the previous example).

  • If you supply a HelpContext ID that can’t be found in a Windows Help file, the contents page for the Help file should be displayed. However, what actually happens is that a Windows Help error is generated, and a message box is displayed that informs the user to contact their vendor. If you supply a HelpContextID that cannot be found in an HTML ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required