Boolean operators and evaluation order

F

F.H. van Zelm

Hi there,

Everyone knows the order for arithmatic operators: first (), then ^, * and /
followed by + and -.
(I know it is a bit more complex than this.)

But what about AND, OR, XOR, EQV and IMP in a combined comparison?
E.g. True AND False OR True. Is it always simply left-to-right, apart from
parenthesis?

I couldn't find information on the Internet and my math is moderate ...

Mvg, Frans
www.fhvzelm.com
 
J

Jay Freedman

Hi there,

Everyone knows the order for arithmatic operators: first (), then ^, * and /
followed by + and -.
(I know it is a bit more complex than this.)

But what about AND, OR, XOR, EQV and IMP in a combined comparison?
E.g. True AND False OR True. Is it always simply left-to-right, apart from
parenthesis?

I couldn't find information on the Internet and my math is moderate ...

Mvg, Frans
www.fhvzelm.com

As far as I can tell, the article "Operator Precedence in Visual Basic"
(http://msdn.microsoft.com/en-us/library/fw84t893.aspx) also applies to VBA.
 
F

F.H. van Zelm

Jay,

Thanks for your attention and help. The article, you mentioned says:
NOT
AND, ANDALSO
OR, ORELSE
XOR
VBA doesn't have ANDALSO and ORELSE whereas EQV and IMP are not
mentioned. Do you have any idea about EQV and IMP?

By the way: is this a general math rule like 'Please exuse my dear aunt
Sally'?

Frans
 
J

Jay Freedman

I should have checked this before: In the Word 2003 VBA help, there is actually
a topic titled "Operator Precedence". It indicates that the order is

Not
And
Or
Xor
Eqv
Imp

I suspect that at this order is more at the discretion of the person specifying
the compiler/interpreter, rather than a generally recognized convention.
 
Top