vbscript – And

OPERATOR:  And


Implemented in version 1.0

And

The And operator is used to perform a logical conjunction on two expressions, where the expressions are Null, or are of Boolean subtype and have a value of True orFalse.

The And operator can also be used a « bitwise operator » to make a bit-by-bit comparison of two integers. If both bits in the comparison are 1, then a 1 is returned. Otherwise, a 0 is returned.

When using the And to compare Boolean expressions, the order of the expressions is not important.

Code:
<% =True And True %>
<% =True And False %>
<% =False And True %>
<% =False And False %>
<% =True And Null %>
<% =Null And True %>
<% =False And Null %>
<% =Null And False %>
<% =Null And Null %>

Output:
True
False
False
False
(Null output)
(Null output)
False
False
(Null output)

Code:
<% anyexpression = True %>
<% someexpression = False %>
<% =anyexpression And someexpression %>

Output:
False

In this example, the And performs a bitwise comparison on the 1 (in binary 001) and the 2 (in binary 010), and returns a 0 (in binary 000).

Code:
<%
Expression1 = 1
Expression2 = 2
Result = Expression1 And Expression2
Response.Write « Result =  » & Result
%>

Output:
Result = 0

Laisser un commentaire

Votre adresse de messagerie ne sera pas publiée. Les champs obligatoires sont indiqués avec *

Vous pouvez utiliser ces balises et attributs HTML : <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>