Does a single VB.NET if-block statement execute when a condition is false? Error VS 2005?

I was wondering if you have encountered this error before: In one IF line, the condition returns FALSE, but then the execution goes to the TRUE part.

Am I doing something wrong here? retries and errorTolerance are Integer types and the screenshot below retries less than errorTolerance . But still he executes the instruction for the True part.

The statement goes to the TRUE part when the condition is False

This overshadows my program, so I did, threw a Throw New Exception on a different line and closed with End If , and it works.

I think my question will be wrong with my previous code?

+4
source share
2 answers

Since I cannot afford not to continue coding, I resorted to the regular If...End If block. Visual Studio and the compiler work fine with the code, although it made me wonder why this expression clouded VS.

+1
source

Turn off optimization to ensure that there is a clear linear correspondence between lines of code and the corresponding compiled instructions.

If it is compilation of the release mode, and retries is only a local variable that goes beyond the scope, the compiler can simply optimize the storage time of the extra value in the register that contains retries initially, but still use this case when checking the expression.

To confirm this, you will see that retries and errorTolerance have the same values ​​in release mode, and retries have a value greater than one after recompiling in debug mode. Inspect the variables separately as you go through the lines.

+1
source

All Articles