检查变量值"没有"
问题描述:
这是我碰到了,去年和SO似乎是一个好地方,记录它:)
This is something I ran into last year, and SO seems like a good place to document it :)
问:当德尔福自动化Excel(/字/ ...),我怎么能检查,如果一个Excel函数返回的变量没有
(因为它被称为在VBA )?
Q: When automating Excel (/Word/...) from Delp how can I check if an Excel function returned the variant Nothing
(as it's called in VBA)?
答
VarIsClear
功能包括你的情况的类型是 varDispatch
和值零
。它还包括空和未知的价值观,以及自定义变量类型。我看到它在我的Delphi 2005的源;我不知道它是如何更早地包括在内。
The VarIsClear
function includes your situation where the type is varDispatch
and the value is nil
. It also includes empty and "unknown" values, and custom variant types. I see it in my Delphi 2005 source; I don't know how much earlier it was included.