Suppose in VB you have:
[tt]IF ((A = B) AND (C < D)) THEN
MyNumber = 10
ELSE
MyNumber = 20
END IF
[/tt]
And in a "C-style" languages it looks like this:
[tt]if ((A == B) && (C < D) {
MyNumber = 10;
}
else {
MyNumber = 20;
}
[/tt]
Suppose your values are:
A = 1
B = 2
C = 3
D = 4
OK. Now your C-Style language will see [tt]A == B[/tt], test for the equivilancy of A and B, and decide that it is false. Since it is false, the entire expression must be false because no matter the result of C < D, the overall expression will be false because both
False and True = False
and
False and False = False
Got it?
OK now VB doesnt work that way.
VB uses the same equal character for an assignment as for an equivilancy test. So where your C-style uses "==" for equivilancy and "=" to assign a value, the VB uses the same for both purposes.
How does VB do it? By context. It interprets the entire line and figures out whether you want an assignment or equivilancy by what makes sense in context of the line.
This is usually a good thing because in English we use the word "equals" for both concepts of equivilancy and assignment... but it is a bad thing in a situation like this because it evaluates the entire line, even though you would think it SHOULD know better after the first half of the conditional is False.
That is why you need to use the embedded conditional statement like DNG showed.