Why is this line not throwing an error: str strVariable = "text"

Why is this line not throwing an error: str strVariable = "text"

Str strTopLeftCellIdentifier = "Account No"

我刚刚找到了我的代码触发错误处理程序的原因。是那一行没有更新 strtopleftcellidentifier 的值。显然,第一个 Str 不应该存在。

然而,它将 运行 那一行。

我知道 Str() 是一个 VBA 函数,但即便如此,我还是不明白它是如何以任何可理解的方式解释该行的。

宏认为它在做什么and/or为什么它没有导致错误?

因为 Str() 是 VBA 中的有效函数名称。所以你的语句实际上是比较 strTopLeftCellIdentifier"Account No" 并将布尔结果传递给 Str()。相当于:

Str False

并且由于您没有捕获 Str() 的 return 值,因此调用时不需要括号。