Author: Tomas Rutkauskas
I am using a function which has a variant in its parameters. Depending on that
value - if that is an integer or a string - I create different returns. What is the
appropriate way to know if the value in a variant type variable is an integer or a
string?
Answer:
1 { ... }2 var3 vt: TVarType;
4 begin5 vt := VarType(v);
6 if vt in [varSmallInt, varInteger, varShortInt, varByte, varWord, varLongWord,
7 varInt64] then8 { ... }9 elseif vt in [varOleStr, varStrArg, varString] then10 { ... }11 else12 raise EVariantError.Create('Unsupported variant type');
13 end;