VBScripts History and Uses
VBScript s History and Uses
Version 1.0 of VBScript was initially introduced in Microsoft Internet Explorer (IE) 3.0, which was released in 1996. Its intended use at that point was to allow web page developers to enhance their pages through client-side scripting. In contrast to plain HTML, which supported the creation of static web pages only, the combination of HTML and client-side script allows the creation of web pages that are both interactive and responsive to the user. For instance, a script could allow the web page to display extended information about hyperlinks as the user's mouse passes over them, or it could be used to validate data entered by the user without submitting it to the server. A script could even be used to generate a web page on the fly, without using any "hardcoded" HTML. The only limitation to VBScript as a language for client-side scripting was that VBScript could be used inside of Internet Explorer only (the only browser to support it) and thus was suitable only for use on corporate intranets that had standardized on Internet Explorer. Using VBScript for client-side scripting on Internet Explorer is discussed in Chapter 8.
Version 2.0 of VBScript was introduced in Internet Information Server (IIS) 3.0 in 1997. The most notable additions to the language were "web-friendly" language elements (such as lightweight Format... functions and the Filter, InStrRev, Reverse, and Join functions) that in most cases were incorporated into the VBA language only with the release of VBA 6.0. In addition, VBScript 2.0 added support for a number of intrinsic constants to make code more readable and also implemented the Const statement to allow user-defined constants. Finally, the CreateObject and GetObject functions were added to instantiate external COM objects; these functions, which are inoperative in a client-side scripting environment, are essential for supporting components that are capable of extending a scripted server-side application.
This new version of VBScript was released with IIS to support server-side scripting using ASP. ASP is itself the object model exposed by IIS that allows your script to access information about the client's request and to write to the server's output stream. An ASP application consists of conventional web pages (that is, HTML and possibly client-side script written in any language) along with script that executes on the server. The output of an ASP script most commonly is HTML, which is simply inserted into the output stream returned by the server in response to a client request. This makes ASP important for several reasons. First, it can be used to produce output that is customized for the browser on which it's displayed. Secondly, it provides a very strong web application environment, particularly one that takes advantage of backend processing. Along with ASP, Microsoft introduced ActiveX Data Objects (ADO) as its primary data access technology. Developing ASP applications with VBScript is discussed in Chapter 5.
Although IIS itself is language-independent and supports a number of available scripting languages, it is precisely in this realmscripting for ASPthat VBScript quickly found its major application.
Version 3.0 of VBScript, released in 1998, had no new language features. Nevertheless, it was significant for marking the spread of VBScript beyond a scripted web environment. Besides IIS Version 4.0 and Internet Explorer Version 4.0, VBScript was now incorporated into Outlook 98 (an interim release of Outlook that was developed out of sync from the other applications in Microsoft Office) andWindows Script Host 1.0.
Windows Script Host (WSH), which first appeared in the Windows NT 4 Option Pack, exposes some core system resources (like the registry, the network, printers, and the filesystem) and allows system administrators to write scripts that access or control them using VBScript, JavaScript, or any of a number of other scripting languages. Using WSH, administrators can write sophisticated scripts that run either locally or remotely to handle typical administrative tasks. WSH is considerably more powerful than typical Windows Shell scripting, and is also available in Windows 98. Microsoft has built the WSH to help companies address the growing concern of the total cost of administration. In addition, WSH appeals to power users who prefer writing a simple script rather than performing a repetitive task multiple times. Scripting for WSH is discussed in Chapter 7.
Microsoft Outlook was originally released in Office 97 as Microsoft's entry into the personal information manager/workgroup messaging market. Outlook featured a number of forms to handle standard MAPI message types (such as messages, contacts, tasks, notes, and appointments) out of the box. However, VBScript made it possible to design new forms and customize their behavior. Although Outlook's latest release,Outlook 2002, includes support for VBA, VBScript remains the programming language for Outlook 2002 forms. Developing Outlook forms with VBScript is covered in Chapter 6.
Version 4.0 of VBScript was also released as part of Visual Studio 6.0 in 1998. As in Version 3.0, no new language features were present. The difference was in the Microsoft Scripting Runtime Library (scrrun.dll ), which now included a File System object model as well as the Dictionary object introduced with VBScript 2.0. The addition of the object model made the library an essential component in any scripted environment.
Version 5.0, which shipped with Internet Explorer 5.0 and IIS 5.0 (which shipped with Windows 2000), added a number of new language enhancements, including support for scripted classes using the Class...End Class construct, support for regular expression searches through the RegExp object, and the ability to dynamically build expressions to be evaluated using the Eval function or executed using the Execute method.
As you can see, even though VBScript's advent as a client-side scripting language was largely unsuccessful, Microsoft remained committed to VBScript as a "lightweight" form of VBA and continued to move the language forward. As a result, it came to be used in a number of environments other than client-side scripts, and in fact, has become one of the major scripting languages in use today.