- The Fundamentals of VBScript
- VBScript Versus VB
- Creating Variables in VBScript
- Concatenating Strings
- Arrays and Loops
- Resizing Arrays
- Inequality Operators
- Conditional Statements
- Select Case Statements
- Working with Arguments
- Beware of Types
- Event Procedure Naming Syntax
- Server-Side Events
- Local Variables
- Script-Level Variables
VBScript Versus VB
The scripting language that we are going to use in this book when it comes to server-side scripting is VBScript. As you might have heard, VBScript is a sub-set of Visual Basic. This means that VBScript shares many of the features of the parent language. The way you evaluate data, make statements, and control program logic in VBScript is almost identical to the way you do these things in Visual Basic. In addition, most of the functions internal to VB can be used in VBScript. However there are some important differences.
VBScript explicitly supports one data type only, the Variant.
VBScript is an interpreted language.
VBScript cannot directly use the Windows API.
There are a few syntactical differences in the use of some internal functions.
You cannot use VBScript to create ActiveX Custom Controls.
You do not use the Visual Basic programming workbenchthe Integrated Development Environment (IDE)to do VBScript programming.
You might come upon some other idiosyncrasies as you continue to work with VBScript. However, for now, these limitations are the ones with which you really need to be familiar. Outside of these limitations, programming in VBScript is not that different from programming in Visual Basic. And, if you decide to use Microsoft's Visual InterDev as your ASP development tool, you'll find that you can have the ease of a visual programming environment, too.
Now that you know how VBScript is positioned as a scripting language for both server and client scripting, let's get down to the nuts and bolts of VBScript programming.
You read earlier that VBScript supports only one data type, the Variant. (Actually, there are situations where you can use specific data types in VBScript. However, you do not do this directly. It's sort of a behind the scenes type of thing. You'll learn more about this is in a bit.)
The Variant is a special data type. It represents all and any data type known to man. Thus you can use a Variant to represent a String, an Integer, and Object, and so on. This versatility does come at a price: the luxury of type safety does not exist in VBScript. Any variable can be of any type at any time.
Let's look at how to create variables in VBScript.