ErrObject.HelpContext 属性

定义

返回或设置一个 Integer,它包含帮助文件中某个主题的上下文 ID。Returns or sets an Integer containing the context ID for a topic in a Help file. 读/写。Read/write.

public:
 property int HelpContext { int get(); void set(int value); };
public int HelpContext { get; set; }
member this.HelpContext : int with get, set
Public Property HelpContext As Integer

属性值

Int32

返回或设置一个 Integer,它包含帮助文件中某个主题的上下文 ID。Returns or sets an Integer containing the context ID for a topic in a Help file. 读/写。Read/write.

示例

此示例使用 HelpContext 对象的属性 Err 来显示错误的 Visual Basic 帮助主题 OverflowThis example uses the HelpContext property of the Err object to show the Visual Basic Help topic for the Overflow error.

Dim Msg As String
Err.Clear()
On Error Resume Next   ' Suppress errors for demonstration purposes.
Err.Raise(6)   ' Generate "Overflow" error.
If Err.Number <> 0 Then
  Msg = "Press F1 or HELP to see " & Err.HelpFile & " topic for" & 
  " the following HelpContext: " & Err.HelpContext
  MsgBox(Msg, , "Error:")
End If

注解

HelpContext属性用于显示应用程序的上下文相关帮助。The HelpContext property is used to display context-sensitive Help for an application. 如果在中指定了帮助文件 HelpFile ,则 HelpContext 使用属性来自动显示标识的帮助文件。If a Help file is specified in HelpFile, the HelpContext property is used to automatically display the Help file identified. 如果 HelpFileHelpContext 属性都为空,则检查属性的值 NumberIf both the HelpFile and HelpContext properties are empty, the value of the Number property is checked. 如果属性的值 Number 与 Visual Basic 运行时错误值相对应,则使用错误的 Visual Basic 帮助上下文 ID。If the value of the Number property corresponds to a Visual Basic run-time error value, then the Visual Basic Help context ID for the error is used. 如果属性的值 Number 不对应于 Visual Basic 错误,则会显示 Visual Basic 帮助文件的内容屏幕。If the value of the Number property does not correspond to a Visual Basic error, the contents screen for the Visual Basic Help file is displayed.

备注

应在应用程序中编写例程来处理典型错误。You should write routines in your application to handle typical errors. 使用对象进行编程时,可以使用对象的帮助文件来提高错误处理的质量,或者在错误不可恢复时向用户显示一条有意义的消息。When programming with an object, you can use 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.

适用于

另请参阅