问题描述
在包含诸如
之类的内容的行的VBA中是否有最大长度:
如果密码=" 1234"或密码=" 1235"或密码= ...............然后
在我看来,在某个阶段,我在
该行并不起作用。我假设它可能是255个字符,但
这条线的工作时间远远长于此。
dixie
它会使用Select Case构造更有效。这可能是你喜欢的任何长度,而且更具可读性。
例如
选择案例密码
Case Is =" 1234"
''在这里运行代码
Case Is =" 1235"
' '在这里运行代码
Case Is =" 1236"
''在这里运行代码
Case Is =" 1237"
''在这里运行代码
Case Is =" 1238"
''运行代码在这里
结束选择
Is there a maximum length in VBA of a line containing stuff like the
following:
If password = "1234" or password = "1235" or password = ............... Then
It seems to me that at some stage, I add an extra password onto the end of
the line and it does not work. I assumed it might be 255 characters, but
the line that works is much longer than that.
dixie
It would be more efficient to use a Select Case construct. That could be
any length you like and alot more readable.
e.g
Select Case password
Case Is = "1234"
''run code here
Case Is = "1235"
''run code here
Case Is = "1236"
''run code here
Case Is = "1237"
''run code here
Case Is = "1238"
''run code here
End Select
这篇关于VBA中If Then行的最大长度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!