VBScript Version 2.0
by Lloyd Borrett
AVBUG Backup, March 1997
The "Active Platform" is Microsoft's strategy
for bringing Internet technology into the easy reach of those
seeking to implement Internet, Intranet and the next generation
of client/server solutions. The strategy involves three core
components: Active Desktop, Active Server and ActiveX controls.
What is VBScript?
Visual Basic Scripting Language (VBScript), a web browser
scripting language based on Visual Basic, is a key part of the
Active Platform. VBScript enables us to activate:
- objects defined by the Internet Explorer object model;
- intrinsic HTML objects such as those used in HTML forms;
- ActiveX controls; and
- Java applets.
VBScript syntax is based on that of Visual Basic (VB), so it
is easily understood by VB programmers. Also like VB and unlike
JavaScript, VBScript is case insensitive. The main difference
between VB and VBScript is that a VBScript variable is almost
typeless. Internally, everything is stored in the variant data
type, which maintains type information and automatically converts
information between types transparently to the programmer.
Microsoft Internet Explorer v3.0 shipped with version 1.0 of
VBScript and JavaScript (Microsoft's Java based scripting
language). Unfortunately, v1.0 of VBScript lacked important
programming features such as constants and the ability to pass by
reference.
VBScript and Netscape Navigator
Netscape Navigator v3.0 doesn't support VBScript, but
NCompass Labs provides a plug-in that implements VBScript.
Unfortunately, I haven't used this plug-in or studied how it
compares to Microsoft's implementation of VBScript. If
you're a Netscape Navigator fan, check it out for yourself
at www.ncompasslabs.com.
VBScript Version 2.0
Microsoft has just released version 2.0 of VBScript and
JScript. You can download the update for Microsoft Internet
Explorer v3 from Microsoft's VBScript home page at www.microsoft.com/vbscript/.
The keywords added to VBScript v2.0 are listed in the
following table:
Category |
New VBScript 2.0 Keywords |
Array handling |
Array, Private,
Public |
Control flow |
For
Each...Next |
Dates/Times |
DateAdd,
DateDiff,
DatePart, Weekday |
Declarations |
Const, Private,
Public |
Formatting
Strings |
FormatCurrency,
FormatDateTime,
FormatNumber,
FormatPercent |
Input/Output |
LoadPicture |
Objects |
CreateObject,
Dictionary,
FileSystemObject,
GetObject, TextStream |
Rounding |
Round |
Script Engine ID |
ScriptEngine,
ScriptEngineBuildVersion,
ScriptEngineMajorVersion,
ScriptEngineMinorVersion |
Strings |
Filter,
InstrRev,
Jain, Replace
Split, StrReverse |
Variants |
TypeName |
Which VBScript Version?
As part of releasing VBScript v2.0, Microsoft is encouraging
programmers who use v2.0 features to refer their users to a page
where they can download the update. As usual, there's an
animated logo to go with this.
It seemed a good idea to put this reminder onto the home page
of the AVBUG website. It also seemed sensible to use the new
Script Engine ID functions to test which version of VBScript was
in use and only notify those users who had the earlier version.
Hence the following VBScript code was written:
<script language="VBScript">
<!--
' Determine the version number.
Dim Version, RequiredVersion
RequiredVersion = 2
Version = ScriptEngineMajorVersion
If Version = 0 Then Version = 1
' Check if up-to-date version
If Version < RequiredVersion Then
' Prompt client
document.write "This site requires you to have_
a newer version of VBScript.<br>"
' Display a button that goes to the MS download page
document.write "<a href=""http://www.microsoft.com/_
msdownload/scripting.htm"" target=""_top"">"
document.write "<img src=""images/vscript.gif"" width=""88"""
document.write "height=""31"" vspace=""0"" border=""0"" alt="""">"
document.write "<img src=""images/leave.gif"" width=""19"""
document.write "height=""8"" border=""0""></a>"
End If
-->
</script>
The first line <script language="VBScript">
tells the web browser that you will be using VBScript. The next
line <!-- effectively comments out the script to web browsers
that don't understand VBScript. The rest is straight
forward. Get the version number, check if it's up-to-date
and write the necessary HTML script to the web page if the user
should update.
The testing phase showed up something interesting. On my
computer the logo wasn't displayed, which was expected as
I'd already updated my Internet Explorer v3.01 to VBScript
v2.0. However, on the next test system, using Internet Explorer
v3.01 without the VBScript v2.0 upgrade, the logo also
wasn't displayed! On a third, supposedly identical, system
the logo was displayed as expected.
Further investigation revealed that the problem system thought
it was using version 3 of VBScript! It seems likely that one of
the many Internet Explorer, VBScript or Visual Basic related beta
add-ons or updates from Microsoft is causing this.
Licensing VBScript
The VBScript interpreter can be easily added to most programs
by simply including the VBScript DLL, which is an OLE server.
Microsoft has made the licensing requirements for adding VBScript
to your programs quite reasonable. Details can be obtained via
the VBScript home page at www.microsoft.com/vbscript/.
For More Information
If you want even more details about VBScript version 2.0,
download the Language Reference and Tutorial from the VBScript
home page.
For more details about the ActiveX Platform, check out
Microsoft's ActiveX home page at www.microsoft.com/activex/.
Last modified: 6:59 am Thursday 25 September 2025
Local time: 4:37 pm Sunday 5 October 2025
|