And 运算符

用于进行2个值的And运算(逻辑或位)。

格式
result = 值1 And 值2

参数

值1、值2
在逻辑And运算中,指定返回逻辑值的值。在位And运算中,指定整数表达式。
result
在逻辑And运算中,返回逻辑值。在位And运算中,返回整数。

说明
逻辑And运算用于组合2个以上的值并输出Bolean型的结果。下表给出And运算的模式。

值1 值2 result
True True True
True False False
False True False
False False False

位And运算用于以位为单位比较两个数值,并按照下表将相应位输出到result中。

值1的位 值2的位 result
0 0 0
0 1 0
1 0 0
1 1 1

参阅
LShift、Mask、Not、Or、RShift、Xor

And运算符使用示例

Function LogicalAnd(x As Integer, y As Integer)

  If x = 1 And y = 2 Then
    Print "The values are correct"
  EndIf
Fend

Function BitWiseAnd()

  If (Stat(0) And &H800000) = &H800000 Then
    Print "The enable switch is open"
  EndIf
Fend

>print 15 and 7
7
>