THE USABLE I NTERFACE
AUGUST, 1996
It now looks as if this Internet-based version of Visual Basic is almost ready, and soon, many of us will use VBScript to build interactive web sites. So far, VBScript is only supported in the Windows 95 beta of Microsoft's Internet Explorer, but look for cross-platform support and support by other browsers in the future.
There are several noticeable differences between Visual Basic, and it's little sister, VBScript. The first of which is the language itself. It is defined as "a strict subset of Visual Basic for Applications", but it provides a good amount of power, including support for ActiveX controls (formally called OLE controls). Please see Figure 1 for a list of supported features.
Another difference is the lack of a development environment (editor, debugger, project manager, etc.). The reason for this is, because all of the code in a VBScript program is contained in the HTML document itself. It also has no ability to create user interfaces. All user interfaces manipulated by a VBS program must be in the HTML document.
VBScript only supports the Variant data type. Therefore, many string and numerical conversion functions are not supported, however, many of the mathematical operators are left intact.
Oh yea, VBScript is free.
Figure 1: VBScript Summary | |||||||||||||||||||||||||||||||||||||||||||||
|
|
<script language="VBScript"> <!-- Document.Write "Hello, World" --> </script>As you can see, the program goes in between the tags. The language property must be set to "VBScript", so that the browser knows which language it's dealing with (remember, VBScript is not the only scripting language running around out there). The code then must be placed inside comment tags (<!-- -->), so that other browsers, not supporting scripting languages, will not spew the program's code out into the document.
Using Document.Write, we can write data to the document, including HTML tags. Cool, eh? Ready for more? Try this...
<script language="VBScript"> <!-- 'Written my Ryan Heldt (rheldt@netins.net) Dim CurrentDate ' Convert Weekday number into text Select Case Weekday(Now) Case 1 CurrentDate = "sunday, " Case 2 CurrentDate = "monday, " Case 3 CurrentDate = "tuesday, " Case 4 CurrentDate = "wednesday, " Case 5 CurrentDate = "thursday, " Case 6 CurrentDate = "friday, " Case 7 CurrentDate = "saturday, " End Select Select Case Month(Now) Case 1 CurrentDate = CurrentDate & "january, " Case 2 CurrentDate = CurrentDate & "february, " Case 3 CurrentDate = CurrentDate & "march, " Case 4 CurrentDate = CurrentDate & "april, " Case 5 CurrentDate = CurrentDate & "may, " Case 6 CurrentDate = CurrentDate & "june, " Case 7 CurrentDate = CurrentDate & "july, " Case 8 CurrentDate = CurrentDate & "august, " Case 9 CurrentDate = CurrentDate & "september, " Case 10 CurrentDate = CurrentDate & "october, " Case 11 CurrentDate = CurrentDate & "november, " Case 12 CurrentDate = CurrentDate & "december, " End Select CurrentDate = CurrentDate & Day(Now) & " " & Year(Now) Document.Write "<font size=4><tt>" & CurrentDate & "</tt></font>" --> </script>This program demonstrates more advanced features of VBscript. See if you can figure it out!
Hopefully you have a basic idea about how VBScript operates and how to use it. In the coming months, you will find out more about this exciting technology, and how to use it effectively in your web sites. Stay Tuned!
For more information on VBScript, visit the VBScript web site.
[About Ryan Heldt: In addition to writing for Visual Basic Online, Ryan also maintains The Toolbox Visual Basic Home Page. He is currently working on World Writer, a HTML authoring tool. Ryan can be reached at rheldt@netins.net]
Click here to go back to the August '96 Article Index