VBScript Syntax

What VBScript syntax refers to, is a set of rules that determine how the language will be written (by the programmer) and interpreted (by the browser or server).

The VBScript syntax is based on the Visual Basic (VB) syntax. VB is a full blown programming environment and VBScript is a scaled down version of VB.

You may also find the VBScript syntax similar to JavaScript in some ways. If you know JavaScript, or any other language for that matter, you will be familiar with terms such as variables, functions, statements, operators, data types, objects etc. VBScript includes these too.

Most of these will be covered throughout the rest of this tutorial. For now, we'll start with the basics.

Basic VBScript Code

Here's some basic VBScript that outputs some text to the browser. Again, if you know JavaScript, this will look familiar.

This results in:

VBScript is similar to JavaScript, but different.

Explanation of Code

The <script> tags are actually HTML, and tell the browser to expect a script in between them. You specify the language using the type attribute. In this case, we're using VBScript.

The part that writes the actual text is only 1 line (document.write("VBScript is similar to JavaScript, but different.")). This is how you write text to a web page in VBScript. This is an example of using a VBScript function (also known as method).

Concatenation

When writing large blocks of text to the screen, you may need to break your code up over many lines. To ensure this doesn't affect the output, you can use an underscore to indicate a concatenation (joining two lines together).

This results in:

The VBScript syntax allows you to concatenate multiple lines together, so that they appear joined together seamlessly