Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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:

  • Leaders
Posted

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.

[sIGPIC]e[/sIGPIC]

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...