Alex Rivera | Logout

What is the operator precedence order in Visual Basic 6.0?

Asked 2008-09-10T20:14:07.983
17

What is the operator precedence order in Visual Basic 6.0 (VB6)?

In particular, for the logical operators.

Edit
Report

1 Answer

3

Use parentheses


EDIT: That's my advice for new code! But Oscar is reading someone else's code, so must figure it out somehow. I suggest the VBA manual topic Operator Precedence. VBA is 99% equivalent to VB6 - and expression evaluation is 100% equivalent. I have pasted the logical operator information here.

Logical operators are evaluated in the following order of precedence:

Not   
And   
Or   
Xor   
Eqv   
Imp   

The topic also explains precedence for comparison and arithmetic operators.

I would suggest once you have figured out the precendence, you put in parentheses unless there is some good reason not to edit the code.

answered 2009-03-05T15:58:48.787

Your Answer