VB6 always executes the 2nd function even the 1st being False

6

The if in VB6 always executes the 2nd function even if the 1st is False , C # does not execute the 2nd function if the 1st is already false.

How can I put vb6 running the 2nd function, only if the 1st is true?

C # code:

if(CalculoHora() && ValidaDados())
{}

VB6 Code:

if (CalculoHora and ValidaDados) then

end if
    
asked by anonymous 12.03.2018 / 10:50

1 answer

7

This evaluation of logical expressions is known as "short-circuit evaluation": #

Unlike% w / o%, for example,% w / o does not execute this validation, that is, in a sequence of logical operators, all are validated to determine whether the expression is true or false, for example:

If a > b And b > a And b <> a Then

In C# , there are the VB and VB.Net operators that do this.

Here's an English OS answer on this subject: link

The answers confirm that the resource does not exist in AndAlso , and the suggestions are to validate in smaller blocks with OrElse and VB6

Read more here: Short-circuit evaluation in Visual Basic.Net

    
12.03.2018 / 12:26