if x <> empty 等同于 if not isempty(x)
is if x <> empty the same as if not isempty(x)
这两个片段在 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
否;对于类型为 as object
的变体,运算符方法会失败
dim woof
set woof = nothing
msgbox isempty(woof) '// ok -> false
msgbox woof = empty '// object reference not set error
(因为 =
方法会尝试读取对象默认 属性 的值)
这两个片段在 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
否;对于类型为 as object
的变体,运算符方法会失败dim woof
set woof = nothing
msgbox isempty(woof) '// ok -> false
msgbox woof = empty '// object reference not set error
(因为 =
方法会尝试读取对象默认 属性 的值)