VBScript

Last Edited

by

in

Definition of VBScript in Network Encyclopedia.

What is VBScript?

VBScript stands for Visual Basic Scripting Edition, a scripting language developed by Microsoft and designed primarily for use in Web browsers such as Microsoft Internet Explorer. VBScript is a lightweight subset of the more powerful Visual Basic for Applications (VBA) programming language used in Microsoft Office and other Microsoft development platforms.

VBScript Example
VBScript Example

VBScript omits features such as file I/O and direct access to the operating system to provide a secure scripting platform for developing Web-based applications using technologies such as Active Server Pages (ASP). Internet Explorer includes a scripting engine for interpreting and running scripts written in VBScript. VBScript can run on all versions of Microsoft Windows as well as on certain UNIX platforms.

How It Works

You cannot use VBScript to write stand-alone programs. Instead, you must embed script into standard Hypertext Markup Language (HTML) files. The script is executed when a Web browser opens the HTML file. Alternatively, ASP can use VBScript to generate client-side script on the fly.

VBScript Example

The script within an HTML page is enclosed within <SCRIPT> … </SCRIPT> tags. For example, the following HTML segment displays a button that, when pressed, displays a message box that reads “Hello World!”:

<INPUT TYPE=BUTTON VALUE="Click me"
NAME="BtnHello">
<SCRIPT LANGUAGE="VBScript">
Sub BtnHello_OnClick
MsgBox "Hello World!", 0, "An active document"
End Sub
</SCRIPT>

In this code, the <INPUT> tag creates the command button and the <SCRIPT> tag contains the script for the event handler that handles the button click.

How VBScript is use

Although VBScript is a general-purpose scripting language, several particular areas of use are noteworthy. First, it is widely used among system administrators in the Microsoft environment. This situation may change with the promotion and increased use of Windows PowerShell. Second, VBScript is the scripting language for Quick Test Professional, a test automation tool. A third area to note is the adoption of VBScript as the internal scripting language for some embedded applications, such as industrial operator interfaces and human-machine interfaces. The hierarchical DBMS InterSystems Caché (which has its roots in the language MUMPS) also supports an implementation of VBScript, Cache BASIC, for programming stored code.

VBScript omits several useful features of the full Visual Basic, such as strong typing, extended error trapping and the ability to pass a variable number of parameters to a subroutine. However, its use is relatively widespread because it is easy to learn and because those who implement code in the language need not pay royalties to Microsoft as long as the VBScript trade mark is acknowledged. When an organization licenses Visual Basic for Applications (VBA) from Microsoft, as companies such as Autodesk, StatSoft, Great Plains Accounting and Visio (subsequently acquired by Microsoft) have done, it is allowed to redistribute the full VBA code-writing and debugging environment with its product.

See also:

Search