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

Examples of Expressions

This section provides a tutorial example showing you different types of expressions.

Now let me try to show you some expressions in an example script, expression.html:

<html>
<body>
<!-- expression.html
 - Copyright (c) 2015, HerongYang.com, All Rights Reserved.
-->
<pre>
<script language="vbscript">
'  Expressions with a single data literal
   document.writeln("")
   document.writeln(777)
   document.writeln(0.00314159e30)
   document.writeln(TRUE)

'  Expressions with a single operation
   document.writeln("")
   document.writeln(3.333e200 + 0.111e200)
   document.writeln(11.0 * 1.0e20)
   document.writeln(1 = 1)
   document.writeln(9.9999e-1 < 1)
   document.writeln(True Or False)

'  Expressions with multiple operations
   document.writeln("")
   document.writeln(+ 1 - 2 * 3 / 4)
   document.writeln(+ 1 - 2 * 3 / 4 = ( + 1 - 2 ) * 3 / 4)
   document.writeln(1 - 2 * 3 / 4 = (1 - 2) * 3 / 4 And 0.9999 < 1)
</script>
</pre>
</body>
</html>

Here is the output of this VBScript example:

777
3.14159E+27
True

3.444E+200
1.1E+21
True
True
True

-0.5
False
False

All results look correct to me.

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

Examples of Expressions - Updated in 2015, by Dr. Herong Yang