lundi 23 novembre 2015

Does an OR statement check all criteria if it has already found a FALSE criteria?

In VBA, when you use the OR statement, will the processor check through all criteria regardless of whether it has already found a FALSE statement?

i.e. for:

If CriteriaA OR CriteriaB OR CriteriaC OR CriteriaD Then
    Exit Function
End If

If CriteriaA is false, will the other criteria be checked unnecessarily? And is CriteriaA always checked first?

I'm wondering since each of these checks takes a significant amount of time and I only need to know whether one is false. In this case, I have put the most commonly failed criteria check first in the list, so that it will cause the function to fail before having to do any more work. Is this a correct assumption?

Aucun commentaire:

Enregistrer un commentaire