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

Introduction to Numeric Comparison Operations

This section provides a quick introduction of numeric comparison operations supported by VBScript: Equal to, Not equal to, Greater than, Less than, Greater than or equal to, Less than or equal to.

Numeric comparison operations are operations that:

  • Operates on two numeric operands.
  • Produces a Boolean value by applying the comparison operation specified by the operator.

There are 6 numeric comparison operations supported in VBScript:

  • Equal to (=): Resulting (True) if two operands are numerically equal.
  • Not equal to (<>): Resulting (True) if two operands are numerically not equal.
  • Greater than (>): Resulting (True) if the first operand is numerically greater than the second operand.
  • Less than (<): Resulting (True) if the first operand is numerically less than the second operand.
  • Greater than or equal to (>=): Resulting (True) if the first operand is numerically greater than or equal to the second operand.
  • Less than or equal to (<=): Resulting (True) if the first operand is numerically less than or equal to the second operand.

To show you how numeric comparison operations work, I wrote the following script, comparison_operation.html:

<html>
<body>
<!-- comparison_operation.html
 - Copyright (c) 2015, HerongYang.com, All Rights Reserved.
-->
<pre>
<script language="vbscript">
   document.writeln(1 = 1)
   document.writeln(1 <> 1)
   document.writeln(9.9999e-1 > 9.99999e-1)
   document.writeln(9.9999e-1 < 1)
   document.writeln(9.9999e-1 >= 0.99999)
   document.writeln(1.00000001 <= 1)
</script>
</pre>
</body>
</html>

Here is the output of this VBScript example script:

True
False
False
True
True
False

No surprises in the output. But the equal to operator sign (=) is identical to the assignment operator. We need to be careful.

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

Introduction to Numeric Comparison Operations

 Introduction to Logical Operations

 String Operations - Concatenation and Comparison

 Variable Declaration and Assignment Statement

 Expression and Order of Operation Precedence

 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

Introduction to Numeric Comparison Operations - Updated in 2015, by Dr. Herong Yang