Skip to Content
VB.NET Language in a Nutshell, Second Edition
book

VB.NET Language in a Nutshell, Second Edition

by Steven Roman PhD, Ron Petrusha, Paul Lomax
April 2002
Intermediate to advanced
688 pages
19h 51m
English
O'Reilly Media, Inc.
Content preview from VB.NET Language in a Nutshell, Second Edition

Name

Err.HelpContext Property

Class

Microsoft.VisualBasic.ErrObject

Syntax

Err.HelpContext

Description

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

Rules at a Glance

  • The Err object sets the HelpContext property automatically when an error is raised if Err.Number is a standard VB.NET error.

  • If the error is user-defined and you don’t explicitly set the HelpContext property yourself, the Err object will set the value to 1000095, which corresponds to the “Application-defined or object-defined error” help topic in the VB Help file. (The HelpContext property is set by the fifth parameter to the Err.Raise method.)

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

Example

Sub TestErr(  )

On Error GoTo TestErr_Err
    
    Dim i
    i = 8

    MsgBox(i / 0)
    
TestErr_Exit:
    Exit Sub

TestErr_Err:
    MsgBox(Err.Description, vbMsgBoxHelpButton, "ErrorVille", _
        Err.HelpFile, Err.HelpContext)
    Resume TestErr_Exit

End Sub

Programming Tips and Gotchas

  • You can display a topic from the Visual Basic Help file by using the MsgBox function with the vbMsgBoxHelpButton constant and passing Err.HelpContext as the HelpContext argument (as shown in the previous example). While this is a simple and very effective way to add much more functionality to your applications, bear in mind that some of your users could find ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

VB .NET Language in a Nutshell

VB .NET Language in a Nutshell

Steven Roman PhD, Ron Petrusha, Paul Lomax

Publisher Resources

ISBN: 0596003080Supplemental ContentCatalog PageErrata