NOTE : A Scripting Reference is now included in this HTMLib. This details various methods of invoking scripts, event handlers that can be included in various standard HTML elements and an Object Model Comparison between Internet Explorer and Netscape. For some more Visual Basic Script information, see the Scripting Reference topics.
To use Visual Basic Script within a HTML document, the code needs to be wrapped in
"VBScript". Visual Basic Script comes into its 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.
NOTE : Internet Explorer only supports external Visual Basic Script files from 3.02 onwards. The script file is just a text file, containing the functions etc., of the script required by the document and can have any extension (proper MIME type mapping will be required to ensure correct functionality)
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.
<!-- These comment delimiters ensure the code is hidden from those browsers that do not support Visual Basic Script
MsgBox "Hello, It's a fine day"
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.)
NOTE : Netscape will not display or work the following scripted examples properly.
Here is another, more involved example. There isn't really room to put all the example code in here, so use the View Source option (via a right mouse click in Internet Explorer) to see how this is done. It's a version of the ever popular Scissors, Paper, Stone game, done entirely in Visual Basic Script. It keeps a running score and even offers some criticism on how the game went if the scores are refreshed. Ever so simple to do, see for yourself (view the source and watch out for the comments)
|Scissors, Paper, Stone, using Visual Basic Script|
|Drawn :||I've won :||You've won :|
The 'Activated Colour Wizard' (an ActiveX/Visual Basic Script based Web application) should also be viewed as an example of ActiveX/Visual Basic Script interaction. To see the example, go to the ActiveX/VBScript examples topic.
© 1995-1998, Stephen Le Hunte
|file: /Techref/language/html/ib/Scripting_Reference/vbscrip.htm, 9KB, , updated: 2006/1/22 21:56, local time: 2020/10/28 13:03,
|©2020 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions?|
<A HREF="http://massmind.ecomorder.com/techref/language/html/ib/Scripting_Reference/vbscrip.htm"> Visual Basic Script</A>
|Did you find what you needed?|
Welcome to ecomorder.com!
Welcome to massmind.ecomorder.com!