views:

236

answers:

2

In variants.pas, there is several VarIsXXX( )-functions for type-checking a variant. There is no VarIsBoolean( ), though.

What's your preferred way of checking if a variant is of type boolean?

+12  A: 

Try

varIsType(v, varBoolean);

It is easy then to write your own VarIsBoolean function

function VarIsBoolean(const V: Variant): Boolean;
begin
   result := varIsType(v, varBoolean);
end;
Ralph Rickenbach
A: 

Unfortunately when converting a variant to a boolean, the Delphi rtl first tries boolean and after that tries integer. Thus the error "Cannot convert variant xxx to integer" when you are actually converting a null variant to a boolean.

dummzeuch
How is that answer to this question?
Rob Kennedy