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.
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 (or contained in a separate text file and referenced using the SRC="URL" attribute). As with JavaScript, the LANGUAGE attribute is required, in this case needing the value "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.
<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>
NOTE : Netscape will not activate the script on pressing the button. It can be made to act similarly using JavaScript.
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.
Examples
NOTE : Netscape will not display or work the following scripted examples properly.
This is the Visual Basic Script version of the example given on the JavaScript page. It gives a greeting according to the time of day.
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
Questions:
file: /Techref/language/html/ib/Scripting_Reference/vbscrip.htm, 9KB, , updated: 2006/1/22 20:56, local time: 2024/12/26 16:19,
18.117.101.250:LOG IN
|
©2024 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.org/techref/language/html/ib/Scripting_Reference/vbscrip.htm"> Visual Basic Script</A> |
Did you find what you needed? |
Welcome to massmind.org! |
Welcome to massmind.org! |
.