帮你把计算顺序理了下 ((1.5 + 3 \ 2) > 2) Or (((7 Mod 3) < 4) And (Not 1)) =(2.5>2) or ((1<4) and (not 1)) =true or ( true and -2) =true or -2 =-1 其中 true=&HFFFF not 1 =&HFFFE=-2
明确需要求 Boolean 结果就用 CBool() 函数转换
运算优先级的问题 和 与数转换的问题关于优先级,一楼已经说过了. 对于运算产生的数据类型如下 Boolean or Boolean And Integer 当类型不一时,就存在类型转换,Boolean转换成Integer再运算,所以就有 -1 or -1 and -2 得结果 -1
((1.5 + 3 \ 2) > 2) Or (((7 Mod 3) < 4) And (Not 1))
=(2.5>2) or ((1<4) and (not 1))
=true or ( true and -2)
=true or -2
=-1
其中
true=&HFFFF
not 1 =&HFFFE=-2
对于运算产生的数据类型如下
Boolean or Boolean And Integer
当类型不一时,就存在类型转换,Boolean转换成Integer再运算,所以就有
-1 or -1 and -2
得结果 -1