VBScript Tutorials - Herong's Tutorial Examples - v6.02, by Herong Yang
IE Option Setting - Enable Script Debugging
This section provides a tutorial example on how to enable the script debugging option in IE 6.0 to watch the runtime error message raised from a VBScript example code.
Since we have been using Internet Explorer (IE) as the host environment in previous sections, let's look at what will IE do when the VBScript raises a runtime error.
IE 6.0 supports an option called "Disable Script Debugging (Internet Explorer)" on the "Advanced" tab. Let's uncheck it, meaning enable script debugging as shown in the picture below:
Now run the following VBScript example:
<html> <body> <!-- runtime_error.html - Copyright (c) 1998 HerongYang.com. All Rights Reserved. --> <pre> <script language="vbscript"> document.writeln("Before statement: x = 1/0") x = 1/0 ' Division by zero document.writeln("Before statement: y = CInt(777777)") y = CInt(777777) ' Overflow document.writeln("Before statement: y = CInt(777777)") z = 1 + "2nd" ' Type mismatch document.writeln("End of test") </script> </pre> </body> </html>
You should get a dialog box with this message:
A Runtime Error has occurred. Do you wish to Debug? Line: 8 Error: Division by zero
You can click the "No" button to close the dialog box.
What happened in the example:
Table of Contents
Introduction of VBScript - Visual Basic Scripting Edition
Variant Data Type, Subtypes, and Literals
Numeric Comparison Operations and Logical Operations
String Operations - Concatenation and Comparison
Variable Declaration and Assignment Statement
Expression and Order of Operation Precedence
Statement Syntax and Statement Types
Array Data Type and Related Statements
Array References and Array Assignment Statements
Conditional Statements - "If ... Then" and "Select Case"
Loop Statements - "For", "While", and "Do"
"Function" and "Sub" Procedures
Inspecting Variables Received in Procedures
►Error Handling Flag and the "Err" Object
►IE Option Setting - Enable Script Debugging
"On Error Resume Next" - Turning on Error Handling
"On Error GoTo 0" - Turning off Error Handling
"Err.Number" and "Err.Clear()" - Error Code and Clear Method
Built-in "Err" Object Properties and Methods
"Err.Raise()" - Raising Your Own Errors
Regular Expression Pattern Match and Replacement
scrrun.dll - Scripting Runtime DLL Library
IE Web Browser Supporting VBScript