VBScript is one of a number of technologies (including Active Server Pages (ASP), JavaScript) available to incorporate interactive elements on a web page. Standard HTML code is static - whatever elements the author incorporated into a page will not chnge unless the HTML code is changed. However, incorporating a script into a web page allows certain elements to respond to user input. For example, VBscript can be used on a form to verify that information being submitted conforms to the desired format. VBScript is one implementation of Dynamic HTML (dHTML) - a method of changing the appearance of a web page "on the fly" and without intervention from the author.
The intent of this page is to provide some very basic example of how VBscript can be incorporated into HTML to "liven-up" a web page. It assumes the user has a basic understanding of the Web and HTML authoring as well as working knowledge of Visual Basic programming. See the references in the conclusions section below for tutorials on these topics.
VBScript was first introduced in Microsoft Internet Explorer 3.0 and is automatically installed by Windows 95a or later, Windows NT 4 or later, Internet Explorer 3 or later, Internet Information Server 3 or later, Outlook 98, Visual Studio 98, and Office 2000. To check if it installed on your machine, look for the SCRRUN.DLL file in your system directory (\Windows\System or \WinNT\System32 folder). If needed, the latest version of this file can be downloaded from Microsoft's Web site.
VBScript is a scripting language developed by Microsoft to extend the functionality of standard HTML. The language is a subset of the Visual Basic Programming Language and has a very similar command syntax. The technology was developed in response to competing technologies (such as JavaScript) and as a way of expanding the usefulness and functionality of standard HTML.
VBscript can be incorporated into a web page by adding a few
commands to the HTML code. First, the <SCRIPT
Language="VBScript"> tag tells the browser that the
page to be displayed contains a script and it is of the type
VBScript. Because not all browsers are able to processVBScript, the
rest of the code should be enclosed in comment tags <!--
--> so that these browsers will ignore the code and not
clutter the page. The examples below show how these codes are used
and some of the basic VBScript commands.
Note: These examples require a VBScript capable browser. We recommend Microsoft's Internet Explorer for Windows.
The first example is - of course - a program to display the "Hello World!" message on the web-page.
|
Click Hello World, Example 1 to see what this code will do.
The "HelloWorld!" message could have just as easily been displayed using standard HTML code. Example 2 shows a more useful example that changes the page's text based on user response.
Here the script displays a message box, then writes the user's response to the page.
|
Click Hello World, Example 2 to see what this code will do.
This version of Hello World demonstrates how VBScript can be used to get some input from the user and then modify the appearance of the displayed HTML code.
This final example shows how VBScript can be used to interface with ActiveX controls embedded on a web page. This example prompt the user with a Hello World dialog box containing "OK" and "Cancel" buttons. Once the user the selects a button to close the Hello World message, the response is parsed and passed to the ActiveX control (rtbDisplay) to be displayed on screen.
|
Click Hello World, Example 3 to see what this code will do.
Though VBScript can't directly control hardware attached to the computer it is still possible to use the scripting technology to control peripherals. As we demonstrated in Example 3, ActiveX controls can be embedded on a web page and controlled by VBScript. In a previous tutorial we created a client/server system that allowed a keypad connected to a client computer to control peripherals attached to a server using an 8255 PC Interface Card. This system could be extended so that the client would run as a VBScript with an embedded ActiveX Winsock contol to communicate to the server over the internet.
What else can we do with VBScript? As mentioned in the introduction, this is merely a bnrief tutorial on VBScript technology and its uses on webpages. For additional information, check out these websites and additional resources.
|
|
|
|
|
|
|
|
For questions or comments regarding this web page contact me at: gsagolla@dca.net.
Last Updated: 03-Jun-2001