Using VBScript with Internet Explorer 10 or Older

This section provides tutorial example on how to embed a VBScript code in a HTML document to be executed by Internet Explorer 10 or older on the local machine.

Internet Explorer (IE) is a Microsoft application that can be used a Web browser to view Web pages. IE also supports a VBScript host environment that allows you to embed VBScript code into source code of Web pages - HTML documents.

VBScript code embedded in HTML documents will be executed while IE is rendering HTML documents on the browser window. This is also called client side scripting, because script code is executed on the client machine instead of the server machine.

To add VBScript code into your HTML documents, you need to use the "script" tag with the "language=vbscript" attribute. Inside the "script" tag, you can place any number of VB statements. Here is the syntax of adding VBScript code in HTML documents:

... (HTML tags)
<script language=vbscript>
   ... (VB statements)
... (HTML tags)

Now let's try to write our first VBScript code in a HTML document.

1. Open the Notepad to enter the following HTML document:

<script language="vbscript">
   document.write("Hello world! - VBScript")

2. Save the HTML document as hello_vb.html.

3. View the HTML document with IE 10. You should see the following message in the IE window:

Hello world! - VBScript

Congratulations. You have successfully written a VBScript code for the host environment supported in IE!

What happened here was:

Note that:

Table of Contents

 About This Book

Introduction of VBScript - Visual Basic Scripting Edition

 What Is VBScript?

Using VBScript with Internet Explorer 10 or Older

 Using VBScript with Internet Explorer 11

 Using VBScript with Internet Information Services

 Using VBScript with WSH (Windows Script Host)

 Using Visual Basic with Microsoft Access

 VBScript and Supporting Environments

 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

 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)


 Full Version in PDF/EPUB