使用的好处是什么(如果有的话)
If StrComp(strVal1, strVal2, vbTextCompare) = 0 Then
而不是使用
If strVal1 = strVal2 Then
如果在模块级别设置Option Compare Text
,有什么区别吗?
我知道 StrComp 处理 null 场景和 <> 场景,我只对 strVal1 和 strVal2 分配了非空有效字符串的情况感兴趣。
最佳答案
If
Option Compare Text
is set at the module level, is there any difference?
没有。它只是提供更细粒度的控制(没有模块级策略 promise )。但是,如果您可以做出这样的 promise ,请选择x = y
选项:更少的代码总是更好的代码。
关于excel - VB/VBA StrComp 或 =,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/756118/