VBScript Tutorials - Herong's Tutorial Notes
Dr. Herong Yang, Version 4.01

Statements and Grammar

VB Script Tutorials - Herong's Tutorial Notes © Dr. Herong Yang

Data Types and Literals

Variables

Logic Operations

String Operations

Conditional Statements

Arrays

Loop Statements

Functions and Subroutines

Built-in Functions

Variable Inspection

... Table of Contents

This chapter describes:

  • What Is a Statement?
  • Types of Statements

Notes and samples in this chapter are based Visual Basic 6.0.

What Is a Statement?

A Statement is a basic unit of VB source code. Here is some general rules about a VB statement:

1. One line can not have more than one statement.

2. One statement is usually written in one line. If you want to continue a statement into the second line, you should put (_) at the end of the first line like this:

   statement_part_1 _
      statement_part_2

3. Comments can be entered at the end of a statement proceeded with (') like this:

   statement ' comment

4. Statements are case insensitive. This means that all keywords, variable names and procedure names are case insensitive.

Types of Statements

Like any other generic programming language, VB offers a lots of types of statements. I will only list some commonly uses statement types below:

  • Assignment Statement - Assigning values to variables.
  • Call Statement - Invoking sub procedures.
  • Dim Statement - Defining a variable or an array.
  • Do ... Loop Statement - Looping on dynamic conditions.
  • Erase Statement - Erasing data from arrays.
  • Exit Statement - Terminating loops or procedures.
  • For Each ... Next Statement - Looping on every elements of arrays.
  • For ... Next Statement - Looping on incremental variables.
  • Function Statement - Defining function procedures.
  • If Statement - Executing statement blocks conditionally.
  • ReDim Statement - Resetting dynamic-size arrays.
  • Rem Statement - Writing comments
  • Select Case Statement - Executing statement blocks selectively.
  • Sub Statement - Defining subroutine procedures.
  • While Statement - Looping on dynamic conditions.

Conclusions

  • Statements can be continued on the next line with (_) character.
  • VB source code is case insensitive.
Dr. Herong Yang, updated in 2006
VBScript Tutorials - Herong's Tutorial Notes - Statements and Grammar