Imp (operator)

Syntax

expression1 Imp expression2

Description

Performs a logical or binary implication on two expressions.

Comments

If both expressions are either Boolean, Boolean variants, or Null variants, then a logical implication is performed as follows:

 

If the first
expression is

and the second
expression is

then the
result is

 

TRUE

TRUE

TRUE

 

TRUE

FALSE

FALSE

 

TRUE

NULL

NULL

 

FALSE

TRUE

TRUE

 

FALSE

FALSE

TRUE

 

FALSE

NULL

TRUE

 

NULL

TRUE

TRUE

 

NULL

FALSE

NULL

 

NULL

NULL

NULL

 

Binary Implication

If the two expressions are Integer, then a binary implication is performed, returning an Integer result. All other numeric types (including Empty variants) are converted to Long and a binary implication is then performed, returning a Long result.

Binary implication forms a new value based on a bit-by-bit comparison of the binary representations of the two expressions, according to the following table:

 

1

Imp

1

=

1

Example

 

0

Imp

1

=

1

5 01101001

 

1

Imp

0

=

0

6 10101010

 

0

Imp

0

=

1

Imp 10111110

Example

This example compares the result of two expressions to determine whether one implies the other.

Sub Main()
  a = 10 : b = 20 : c = 30 : d = 40

  If (a < b) Imp (c < d) Then
    MsgBox "a is less than b implies that c is less than d."
  Else
    MsgBox "a is less than b does not imply that c is less than d."
  End If

  If (a < b) Imp (c > d) Then
    MsgBox "a is less than b implies that c is greater than d."
  Else
    MsgBox "a is less than b does not imply that c is greater than d."
  End If
End Sub

See Also

Operator Precedence (topic); Or (operator); Xor (operator); Eqv (operator); And (operator).

More information

I