VBScript Tutorials - Herong's Tutorial Examples - Version 5.20, by Dr. Herong Yang

What Is an Expression?

This section provides an introduction of what is an expression. A data literal or a variable is a simple expression. A single operation or a group of multiple operations is a complex express.

Giving a precise single definition of an expression is not an easy task. So I will try to define it in a recursive way:

1. A simple expression is a presentation of a data value like, a literal, a variable, an element of an array, or a function call.

2. A complex expression is a presentation of a data value returned from an operation represented by an operator, and one or two expressions as operands. The operation will result a data value.

If you apply rule #2 recursively, an expression may contain multiple operations in a sequence. When this happens, operations must be carried out in an order defined by the following rules:

A. The operation enclosed in a pair of parentheses must be carried out before an operation outside the parentheses.

B. The operation with a higher precedence must be carried out before an operation with lower precedence.

C. The operation on the left must be carried out before the operation on the right.

D. Rule A must be applied before Rule B, which must be applied before Rule C.

Examples of expressions:

   "Hello world!"   'Simple expression - a String literal
   777              'Simple expression - an Integer literal
   author           'Simple expression - a variable
   Date()           'Simple expression - a function call

   7*9.99           'Complex expression - an arithmetic operation
   "Hello "&author  'Complex expression - a string concatenation
   (7+2)*9.99 > 50  'Complex expression - multiple operations

Table of Contents

 About This Book

 Introduction of VBScript - Visual Basic Scripting Edition

 Variant Data Type, Subtypes, and Literals

 Arithmetic Operations

 Numeric Comparison Operations and Logical Operations

 String Operations - Concatenation and Comparison

 Variable Declaration and Assignment Statement

Expression and Order of Operation Precedence

What Is an Expression?

 Precedences of Operations

 Examples of Expressions

 Statement Syntax and Statement Types

 Array Data Type and Related Statements

 Array References and Array Assignment Statements

 Conditional Statements - "If ... Then" and "Select Case"

 Loop Statements - "For", "While", and "Do"

 "Function" and "Sub" Procedures

 Built-in Functions

 Inspecting Variables Received in Procedures

 Error Handling Flag and the "Err" Object

 Regular Expression Pattern Match and Replacement

 scrrun.dll - Scripting Runtime DLL Library

 Creating Your Own Classes

 IE Web Browser Supporting VBScript

 IIS ASP Server Supporting VBScript

 WSH (Windows Script Host)

 References

 Printable Copy - PDF Version

What Is an Expression? - Updated in 2015, by Dr. Herong Yang