Question regards to if statement (VB.NET)

Worrow

Well-known member
Joined
Jul 10, 2003
Messages
67
I have a question about a if statement below:

if statement1 and statement2 then
.....
endif

IIRC, if statement1 is false, then statement2 will not be evaluated(at least in other language). But in my program, this is not true. Is this normal in VB.NET? :confused:
 
First of all, this question belongs in the syntax specific form. Perhaps a mod will move it for you.

Secondly, the feature that you are refering to is called short-circuiting: when the first value in an and operation evaluates to true, the second value is not evaluated. This feature was previously unavailable as an operator in Visual Basic. In Visual Basic .Net, this feature was added. To use a short-circuited and operation, use the AndAlso operator. The reason that And is not short-circuited is probably for code portability between VB6 and VB.Net.
 
Back
Top