Excel中VBA布尔防爆pression - 操作顺序 [英] Excel VBA Boolean Expression - Order of Operations

查看:207
本文介绍了Excel中VBA布尔防爆pression - 操作顺序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个测试在Excel VBA:

I have a test in Excel VBA:


If (test1) And (test2) And (test3) Then
    'do something
End If

在C,Java等TEST1将会首先运行,然后测试2,然后TEST3。重要的是,如果test1的是假的,整个测试是假的所以其余测试不运行。

In C, Java, etc. test1 would be run first, then test2, then test3. Critically, if test1 is false the whole test is false so the remaining tests do not run.

请问,在这种情况下,用VBA发生的呢?如果是这样,其顺序为运行测试?

Does that happen in this case with VBA? If so, in which order are the tests running?

推荐答案

在各椎体到.NET也因为没有这样的事情短路之前。如果不需要所有前pressions将甚至评估。如果你想短期curcuit,做嵌套国际单项体育联合会。

In all VBs prior to .NET there is no such thing as short-circuit. All expressions will be evaluated even if not required. If you want short-curcuit, do nested IFs.

这篇关于Excel中VBA布尔防爆pression - 操作顺序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆