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) 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.
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.