Operators Overview
Syntax
^ Not * / \ Mod + - << >> & < <= > >= = <> Is IsNot
And AndAlso Or OrElse Xor Eqv Imp
Description
These operators are available for numbers n1 and n2 or strings s1 and s2. If any value in an expression is Null then the expression's value is Null. The order of operator evaluation is controlled by operator precedence.
Operator |
Description |
- n1 |
Negate n1. |
Remainder of the integer value of n1 after dividing by the integer value of n2. |
|
Shift n1 by n2 bits to the left. The number of bits to shift is indicated by the lowest bits of n2: lowest 3 bits when n1 is a SByte/Byte value, lowest 4 bits when n1 is a Integer/UInteger value, lowest 5 bits when n1 is a Long/ULong value, lowest 6 bits when n1 is a Huge_/UHuge_ value. This language element is not VBA compatible. |
|
Shift n1 by n2 bits to the right. The number of bits to shift is indicated by the lowest bits of n2: lowest 3 bits when n1 is a SByte/Byte value, lowest 4 bits when n1 is a Integer/UInteger value, lowest 5 bits when n1 is a Long/ULong value, lowest 6 bits when n1 is a Huge_/UHuge_ value. (For signed numbers the sign bit is propagated to the right.) This language element is not VBA compatible. |
|
Not n1 |
Bitwise invert the integer value of n1. Only Not True is False. |
Bitwise and the integer value of n1 with the integer value n2. |
|
Logical and of n1 with the n2. If n1 is False, n2 is not evaluated. This language element is not VBA compatible.. |
|
Bitwise or the integer value of n1 with the integer value n2. |
|
Logical or of n1 with the n2. If n1 is True, n2 is not evaluated. This language element is not VBA compatible. |
|
Bitwise exclusive-or the integer value of n1 with the integer value n2. |
|
Bitwise equivalence the integer value of n1 with the integer value n2 (same as Not (n1 Xor n2)). |
|
Bitwise implicate the integer value of n1 with the integer value n2 (same as (Not n1) Or n2). |
Example
Sub Main
N1 = 10
N2 = 3
S1$ = "asdfg"
S2$ = "hjkl"
Debug.Print -N1 '-10
Debug.Print N1 ^ N2 ' 1000
Debug.Print Not N1 '-11
Debug.Print N1 * N2 ' 30
Debug.Print N1 / N2 ' 3.3333333333333
Debug.Print N1 \ N2 ' 3
Debug.Print N1 Mod N2 ' 1
Debug.Print N1 + N2 ' 13
Debug.Print S1$ + S2$ '"asdfghjkl"
Debug.Print N1 - N2 ' 7
Debug.Print N1 << N2 ' 80
Debug.Print N1 >> N2 ' 1
Debug.Print N1 & N2 '"103"
Debug.Print N1 < N2 'False
Debug.Print N1 <= N2 'False
Debug.Print N1 > N2 'True
Debug.Print N1 >= N2 'True
Debug.Print N1 = N2 'False
Debug.Print N1 <> N2 'True
Debug.Print S1$ < S2$ 'True
Debug.Print S1$ <= S2$ 'True
Debug.Print S1$ > S2$ 'False
Debug.Print S1$ >= S2$ 'False
Debug.Print S1$ = S2$ 'False
Debug.Print S1$ <> S2$ 'True
Debug.Print N1 And N2 ' 2
Debug.Print N1 AndAlso N2 ' True
Debug.Print N1 Or N2 ' 11
Debug.Print N1 OrElse N2 ' True
Debug.Print N1 Xor N2 ' 9
Debug.Print N1 Eqv N2 ' -10
Debug.Print N1 Imp N2 ' -9
End Sub