Re: Not = versus <>
- From: argusy <argusy@xxxxxxxxxxxxxxx>
- Date: Mon, 23 Oct 2006 11:20:58 +0930
Larry (and Mike and Bob)
Yeah... you're right.
The not operator inverts **everything** bitwise
(so 22 becomes -23) - I fergitted that,
and VB precedence evaluates the = first
(and THAT I should NOT have forgotten because it's so common)
Irrespective of my major boo-boo, I hope the OP realises the difference
with the two if's, and that a program could blow up if he/she uses the wrong algorithm.
Graham
Larry Serflaten wrote:
"argusy" <argusy@xxxxxxxxxxxxxxx> wrote
For the sake of clarity, lets give val and someval numbers (22 and 66)
the 'Not' before 'val' is going to evaluate the left side as "true" (-1),
because val, as 22, is regarded as "False". "Not false" equates to "True"
The statement is now
If "true" = 66 then ' and it isn't!!!
Evaluation order is known as Precedence. According to VB Help,
arithmetic operators are evaluated first, comparison operators next,
and logical operators last, so including parentheses for clarity and
adding in your values, the evaluation would have been:
If Not (22 = 66) Then .... ' True
Or
If Not (False) Then ...
HTH
LFS
.
- Follow-Ups:
- Re: Not = versus <>
- From: David Kerber
- Re: Not = versus <>
- References:
- Not = versus <>
- From: MP
- Re: Not = versus <>
- From: argusy
- Re: Not = versus <>
- From: Larry Serflaten
- Not = versus <>
- Prev by Date: Re: Form size question....
- Next by Date: Re: Internet explorer 7 for windows xp sp2
- Previous by thread: Re: Not = versus <>
- Next by thread: Re: Not = versus <>
- Index(es):
Relevant Pages
|