NOTE : A Scripting Reference is now included in this HTMLib. This details various methods of invoking scripts in HTML and also event handlers that can be included in various standard HTML elements. For some more Visual Basic Script information, see the Scripting Reference topics.
Visual Basic Script recently introduced by Microsoft represents a step further towards active web pages. Like JavaScript, Visual Basic Script provides scripting, automation and customisation capabilities for Internet Explorer. It is a subset of the Visual Basic programming language that is fully compatible with Visual Basic and Visual Basic for Applications.
To use Visual Basic Script within a HTML document, the code needs to be wrapped in <SCRIPT> ... </SCRIPT>
elements, just like JavaScript. As with JavaScript, the LANGUAGE attribute is required, in this case needing the value "VBScript"
. Visual Basic Script comes into it's own when used in conjunction with ActiveX OLE controls, which allow for full automation with any OLE compliant application, but can be used for almost any purpose on a page, allowing for truly interactive web sites to be created relatively easily.
The following code section, assigns the action described in the script (namely that a message box pops up when the button is pushed) to the button, named 'btnHello' which has been embedded within the page.
<SCRIPT LANGUAGE="VBScript">
<!-- These comment delimiters ensure the code is hidden from those browsers that do not support Visual Basic Script
Sub btnHello_OnClick
MsgBox "Hello, It's a fine day"
End Sub
-->
</SCRIPT>
The button, called 'btnHello' responds to being clicked by displaying a message box with the text "Hello, It's a fine day". For information on how to embed ActiveX controls, see the <OBJECT>
element. (The button in the above example was embedded into the page using a standard <INPUT TYPE=BUTTON>
element. For more details, see the Forms section.)
As with JavaScript, a complete description of Visual Basic Script is well outside the scope of this reference and you are encouraged to visit http://www.microsoft.com/vbscript/ for more information and a complete copy of the language documentation.