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

Comparison and Logic Operations

Part:   1  2  

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

(Continued from previous part...)

Logical Operations

Logical operations are operations that:

  • Operates on one Boolean operand or two Boolean operands.
  • Produces a Boolean value by applying the logical operation specified by the operator.

There are 4 logical operations supported in VB:

  • Logical add (Add): Resulting (True) if both operands are (True).
  • Logical or (Or): Resulting (True) if one of the operands is (True).
  • Logical not (Not): Resulting (True) if the operand is (False).
  • Logical xor (Xor): Resulting (True) if one and only one operand is (True).

To show you how logical operations work, I wrote the following script, logical_operation.html:

<html>
<body>
<!-- logical_operation.html
   Copyright (c) 2006 by Dr. Herong Yang. http://www.herongyang.com/
-->
<pre>
<script language="vbscript">
   document.writeln(True And True)
   document.writeln(True Or True)
   document.writeln(Not True)
   document.writeln(True Xor True)
</script>
</pre>
</body>
</html>

Here is the output:

True
True
False
False

No surprises in the output.

Conclusions

  • VB supports 6 numeric comparisons.
  • VB supports 4 logical operations.

Part:   1  2  

Dr. Herong Yang, updated in 2006
VBScript Tutorials - Herong's Tutorial Notes - Comparison and Logic Operations