VBScript Tutorials - Herong's Tutorial Examples - Version 5.20, by Dr. 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:
Enable Script Debugging in IE

Now run the following VBScript example:

<html>
<body>
<!-- runtime_error.html
 - Copyright (c) 2015, 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.
IE Runtime Error

What happened in the example:

  • When IE tries to execute the "x = 1/0" statement, a runtime error "Division by zero" is raised.
  • IE stops executing the rest of the VBScript code, because the error handling flag is turned off by default.
  • IE displays a dialog box asking your confirmation to start the debugging tool.
  • "Err" object properties are printed on the dialog box, telling us the type of error, and where it occurs.

Table of Contents

 About This Book

 Introduction of VBScript - Visual Basic Scripting Edition

 Variant Data Type, Subtypes, and Literals

 Arithmetic Operations

 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

 Built-in Functions

 Inspecting Variables Received in Procedures

Error Handling Flag and the "Err" Object

 Error Handling Rules Overview

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

 Creating Your Own Classes

 IE Web Browser Supporting VBScript

 IIS ASP Server Supporting VBScript

 WSH (Windows Script Host)

 References

 Printable Copy - PDF Version

IE Option Setting - Enable Script Debugging - Updated in 2015, by Dr. Herong Yang