Worrow Posted May 18, 2005 Posted May 18, 2005 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: Quote
Leaders snarfblam Posted May 18, 2005 Leaders Posted May 18, 2005 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. Quote [sIGPIC]e[/sIGPIC]
Worrow Posted May 18, 2005 Author Posted May 18, 2005 It works! Thanks a lot. Sorry about the wrong forum :o Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.