这两个片段在 VBScript 中是否等效?
If x <> empty
'do something
End if
If not isempty(x)
'dosomething
End if
上下文:
我想重写一个条件
If ((Not IsEmpty( Var ) ) And ( Var <> "" ) ) Then
简洁一点
If Var <> Empty And Var <> "" Then
最佳答案
没有;对于类型为对象的变体,运算符方法会失败
dim woof
set woof = nothing
msgbox isempty(woof) '// ok -> false
msgbox woof = empty '// object reference not set error
(因为 =
方法会尝试读取对象的默认属性的值)
关于if-statement - is if x <> empty 与 if not isempty(x) 相同,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41282500/