Here's a trick when working with IF statements -- Consider them to all have an implied " <> 0 " that they evaluate against.
IF i THEN...
In all truth, the above statement evaluates as if:
IF i <> 0 THEN... The <> 0 is the implied final comparison.
So when i = -10, the check for -10 <> 0 is true.
when i = -9, the check for -9 <> 0 is true.
When we get down to i = 0, the check for 0 <> 0 is false.
Even if you have a more explicit IF statement, that implied <> 0 is still there at the end.
a = 3
IF a <> 2 THEN ...
The above gets resolved basically as IF (a <> 2) <> 0 THEN... (the red is the implied truth check)
a <> 2 becomes 3 <> 2... that's true, so we have a result of -1. (The value BASIC returns for truth comparisons.)
-1 <> 0 is true... So, at the end of the day, a <> 2 is true.
Change the value of a to 2, and we find:
a = 2
IF a <> 2 THEN....
Same as before, the above gets resolved basically as IF (a <> 2) <> 0 THEN... (the red is the implied truth check)
a <> 2 becomes 2 <> 2... that's FALSE, so we have a result of 0. (Remember, in BASIC, FALSE is always ZERO.)
0 <> 0 is false... So, at the end of the day, a <> 2 is false when a is 2.
All IF statements basically have an implied <> 0 to their evaluation. When you keep that in mind, the FOR.. NEXT loop which I showed above makes perfect sense.
For i = -10 To 10
Print i;
If i <> 0 Then Print "TRUE" Else Print "FALSE"
Next
If it's not false (ZERO), then it's true. ;)