Introduction to VBScript

Microsoft Visual Basic Scripting (VBScript) Language brings active scripting to a wide variety of environments, including Web client scripting in Microsoft Internet Explorer and Web server scripting in Microsoft Internet Information Service (IIS).

Microsoft Visual Basic Scripting (VBScript) Language brings active scripting to a wide variety of environments, including Web client scripting in Microsoft Internet Explorer and Web server scripting in Microsoft Internet Information Service (IIS).

Environments Where VBScript Can Run

VBScript is a client-side scripting language. It is a light version of Microsoft Visual Basic. The syntax of VBScript is very similar to that of Visual Basic.

VBScript cannot run its code on its own. It needs a bigger programming language to host it. Right now, there are 3 environments where VBScript can run.

  • IIS (Internet Information Server) – Microsoft’s web server
  • WSH (Windows Script Host) – The native hosting environment of the Windows OS
  • IE (Internet Explorer) – The simplest hosting environment we can use to run VBScripts

Disadvantages of VBScript

  • The main disadvantage of VBScript is that most browsers except Internet Explorer will not process VBScript code.
  • VBScript will not run on computers that run on operating systems other than Microsoft Windows including Linux, Mac etc.

Where Should I write the Program?

We should write VBScript code in Notepad. Now, VBScript is used as the default scripting language of ASP. Example:

Dim i
i = 10
MsgBox i

VBScript is not Case Sensitive.

How Did the Program Executed?

  • Double Clicking on the File or Windows Explorer
  • Command Prompt

Two Program Works for VBScript Program Execution:

  1. Wscript.exe (Windows Explorer)
  2. Cscript.exe (Command Prompt)

Comments

Comments is something will not be executed, it’ll be skipped. Use to write a comment. You can also use Rem keyword. For example,

  • ‘Created By: Noor Hossin, Nov-19-2014, 8:13 PM
  • Rem Instead of ‘ we can use Rem keyword

Using keyboard select the area and press ctrl+M. To remove Comments, select the comments and press ctrl+shift+M.

White Spaces

  • Any white spaces in VBScript will be ignored, except in string.
  • New line will not be ignored.