|
Comparison and Logic Operations
Part:
1
2
(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
|