VB 里面的 Is Nothing 在Delphi 怎么写呢 就是判断Com对像是是不为空 怎么写呢 varisempty不行 ( 积分: 10 )

  • 主题发起人 主题发起人 goddy
  • 开始时间 开始时间
G

goddy

Unregistered / Unconfirmed
GUEST, unregistred user!
VB 里面的 Is Nothing 在Delphi 怎么写呢 就是判断Com对像是是不为空 怎么写呢 varisempty不行
 
VB 里面的 Is Nothing 在Delphi 怎么写呢 就是判断Com对像是是不为空 怎么写呢 varisempty不行
 
用VarIsNull看看
 
如果V是要判断的对象的话,先将V转换成TVarData,再判断其VDispatch是否为空。如果为空,这个Com对像就是空的。如:
if TVarData(V).VDispatch=nil then ....
 
VarIsEmpty

Description

VarIsEmpty returns true if the given variant contains the value Unassigned. If the variant contains any other value, the function result is false.

Note: VarIsEmpty does not indicate when a Variant that represents an interface has had the interface pointer cleared or when a custom Variant is clear. If either of these situations may exist, use the VarIsClear method instead.
Note: Do not confuse an unassigned variant with a Null variant. A Null variant is still assigned, but has the value Null. Unlike unassigned variants, Null variants can be used in expressions and can be converted to other types of variants.

VarIsClear

Description

VarIsClear returns true if the given variant抯 value is undefined. The value can be undefined for any of several reasons:

The Variant may have had its value set to Unassigned.
The Variant抯 value may be an interface type that has been set to nil (Delphi) or NULL (C++).
The Variant may be a custom variant that returns true from its IsClear method.

In all other cases, the function result is false.

Note: Do not confuse an unassigned variant with a Null variant. A Null variant is still assigned, but has the value Null. Unlike unassigned variants, Null variants can be used in expressions and can be converted to other types of variants.
你说该用哪个?
 
VarIsClear 可以了
 

Similar threads

回复
0
查看
804
不得闲
S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
D
回复
0
查看
2K
DelphiTeacher的专栏
D
D
回复
0
查看
2K
DelphiTeacher的专栏
D
后退
顶部