P1: JDT
WL040C-44 WL040/Bidgoli-Vol III-Ch-51 June 23, 2003 16:33 Char Count= 0
622 VISUALBASICSCRIPTINGEDITION(VBSCRIPT)Table 1VBScript Major Version Release HistoryVBScript Year of
Version Release Comment
1.0 1996 VBScript introduced in conjunction with version 3 release of Microsoft Internet Explorer.
2.0 1997 Coincided with version 3 release of IIS. Added several language enhancements, including support
for instantiation and exploitation of external COM objects.
3.0 1998 Coincided with first release of WSH. No new language features, but the scripting runtime library
for this release did add FileSystemObject.
4.0 1998 Coincided with release 6.0 of Microsoft Visual Studio. No notable new features were added
with this release.
5.0 1999 Added intrinsic scripting engine support for regular expressions, added more features for object
handling, and enabled the creation of object classes using VBScript.How Microsoft Implements
Scripting Languages
The Microsoft model of scripting distinguishes between
“scripting hosts” and “scripting engines.” Scripting en-
gines process and execute scripts fed to them by scripting
hosts. Scripting hosts are applications that provide script
context and environment (including a host application
object model) and instantiate instances of appropriate
scripting engines to execute scripts. This modular ap-
proach to scripting allows multiple applications to use
the same scripting engine. It also allows multiple script-
ing engines, each designed to handle a particular lan-
guage of script, to support a single application (script-
ing host). Microsoft has supplied scripting engines for
JScript and VBScript as part of the Windows operating
system since release of Microsoft Windows 98. Scripting
engines for PerlScript, REXX, and Python are available
from third parties. Microsoft also provides sufficient infor-
mation about scripting interfaces to allow programmers
to build their own scripting engines (and scripting hosts).
While the scripting engine is responsible for actually
running your script, it is the responsibility of the script-
ing host to provide the object model that can be used by
your script to access features, functions, and services of
the host application. At the present time Microsoft pro-
vides scripting hosts for Internet Explorer, IIS, Outlook,
and the Windows operating system itself. Each of these
hosts provides an object model specific to its application.
Thus the Internet Explorer scripting host’s object model is
largely based around the W3C document object model and
is used to script client-side features and functions of the
Internet Explorer Web browser. The IIS scripting host’s
object model is used to read HTTP requests and gener-
ate HTTP responses. The WSH’s object model provides
access to essential operating system objects such as the
environment, network, and standard input, output, and
error devices. The Outlook scripting host’s object model
provides access to such Outlook objects as forms, editors,
and converters. The object models for the Internet Ex-
plorer scripting hosts and the WSH are briefly described
in this chapter. The object model for using VBScript in
IIS is dealt with fully in the chapter on ASP and so is not
dealt with here. The use of VBScript in Microsoft Outlook
is outside the intended scope of this encyclopedia and so
is also not addressed here.In addition to object references provided by the script-
ing host, scripts written in VBScript have access to other
properly registered Windows ActiveX and COM object
classes on the host computer. This includes also objects
intrinsic to the VBScript scripting engine (e.g., an object
for processing regular expressions and an object for han-
dling and processing runtime errors) and objects provided
by the Microsoft Scripting Runtime Library (e.g., the Dic-
tionary Object and the File System Object).VBScript Version History
By design most VBScript upgrades have been synchro-
nized with scripting host releases and upgrades (Mi-
crosoft, 2002b). This chapter describes VBScript through
version 5.6, which was released in 2001. Effective with
this release, version numbering for the WSH, VBScript,
JScript, etc. have been made consistent. (Thus, VBScript
release 5.6 coincides with WSH release 5.6.) The first three
major version releases of VBScript coincided with first
releases of new scripting hosts. Version 4 was released
to coincide with the release of version 6.0 of Microsoft
Visual Studio, but added no notable new language fea-
tures. Version 5 added several new language features and
has been maintained for more than two years with minor
release updates, most associated with updates in script-
ing hosts. With the release of Visual Basic.NET, there is
no longer a clear need for a separate Visual Basic script-
ing language. Release 5.6 may be the last release of VB-
Script. Table 1 details major version release history of
VBScript.VBSCRIPT LANGUAGE
FUNDAMENTALS
VBScript Variables, Constants,
and Data Typing
Variables and named constants are constructs used to
represent data employed in a program. Each variable or
named constant is known in code by a symbolic name.
Variables differ from named constants in that variable
values may change during program execution and initial
variable values may be the result of calculations or
manipulations carried on during program execution.
Constants are declared in VBScript using the key word