In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article focuses on "the use of object Err in VBS". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Now let the editor take you to learn "the use of object Err in VBS".
Err
Contains information about runtime errors. Accept the Raise and Clear methods used to generate and clear run-time errors.
Description
The Err object is an inherent object with global scope: you don't have to create an example of it in your code. The properties of Err are set by an error-generator: Visual Basic, automatic object, or VBScript program.
The default property of the Err object is number. Err.Number contains an integer and can be used by the Automation object to return SCODE.
When a run-time error occurs, the properties of the Err are populated with unique information that identifies the error and information that can be used to process it. To generate run-time errors in your code, use the Raise method.
The Err object property is reset to zero or zero length string (""). The Clear method can be used to explicitly reset the Err.
The following example illustrates the use of the Err object:
On Error Resume NextErr.Raise 6 'generated an overflow error. MsgBox ("Error #" & CStr (Err.Number) & "& Err.Description) Err.Clear 'clears the error.
The Err object is an internal object with a global scope that contains all the information about the error.
On Error Resume next ignores all errors generated at run time
On Error Goto 0 cancels ignoring error actions
The main methods are: Clear, Raise
The main attributes are: Description, HelpContext, HelpFile, Number, Source
For a detailed description of its properties and methods, see the following example:
Methods of Err object
Clear
Description: clear all current properties of the Err object, that is, empty errors
Syntax: Err.Clear
Example:
On Error Resume next 'ignores all errors generated at run time
MsgBox 5/0
MsgBox Err.Number 'output the wrong value
Err.Clear 'clear all error messages
MsgBox Err.Number 'output 0
Raise
Description: define a runtime error
Syntax: Err.Raise (number,source,description,helpfile,helpcontent)
Parameter: Number: used to mark the error number
The Source tag produces the wrong object or application name
Description: description information about the error
Valid path to the Helpfile:help file
The theme of the Helpcontent:help file
Example:
On Error Resume Next
Err.Raise 22, "VBS script", "overflow", "c:\ test.txt" 'defines a runtime error
MsgBox "error:" & vbCrLf _
& "Number:" & Err.Number & vbCrLf _
& "Source:" & Err.Source & vbCrLf _
& "Description:" & Err.Description & vbCrLf _
& "Helpfile:" & Err.HelpFile
Err.Clear 'clear error
Properties of the Err object
Description
Description: returns or sets the description of the Error
Syntax: Description (conid)
Example:
Desc = Err.Description 'returns the description of Error
Err.Description = "Type mismatch" 'sets the description information for the Error
HelpContext
Description: returns or sets the topic for the specified help information
Syntax: HelpContext (string)
Example:
HelpContext = Err. HelpContext 'returns the help topic for Error
Err. HelpContext = "Type mismatch" 'set the help topic for Error
HelpFile
Description: returns or sets the address of the help file
Syntax: HelpFile (FilePath)
Example:
HelpFile = Err. HelpFile 'returns the address of the HelpFile
Err. HelpFile = "c:\ test.txt" 'sets the address of the HelpFile
Number
Description: returns or sets a value that represents an error
Syntax: Number (errid)
Example:
Number = Err. Number 'returns the id of Error
Err. Number = "c:\ test.txt" 'sets the id of Error
Source
Description: returns or sets the object (or the name of the application) that reports errors
Syntax: Source (string)
Example:
Source = Err. Source 'returns the object or application name of the Error
Err. Source = "box" 'sets the object or application name of Error
At this point, I believe you have a deeper understanding of "the use of object Err in VBS". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.