Chapter 2. VBScript Essentials

Microsoft Visual Basic scripting edition (VBScript) has long been the favorite scripting language of Microsoft developers and soon it will be your favorite as well. VBScript is easy to learn and use, making the language a great choice, especially if you don't have a programming background.

Working with Variables

Variables are a part of most scripting languages, and VBScript is no exception. A variable is simply a placeholder for a value you want to work with.

Variable naming

You can create a variable by assigning the variable a name, which you can refer to in your code later. Variable names, like other VBScript structures, follow standard naming conventions. These naming rules are as follows:

  • Names must begin with an alphabetic character.

  • Names cannot contain periods.

  • Names must be less than 256 characters in length.

Variable names also have an additional property, which isn't the case of other structures in VBScript. They are case-sensitive, meaning value1, Value1, and VALUE1 are all different variables. However, method, function, and object references in VBScript are not case-sensitive. For example, you can echo to the screen using any of the following commands:

wscript.echo "This is a test!"
Wscript.echo "This is a test!"
WScript.Echo "This is a test!"

But in reality, the correct capitalization for this reference ...

Get Microsoft® PowerShell, VBScript and JScript® Bible now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.