Determine whether the value in a variant type variable is an integer or a string (Views: 717)
Problem/Question/Abstract: 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: { ... } var vt: TVarType; begin vt := VarType(v); if vt in [varSmallInt, varInteger, varShortInt, varByte, varWord, varLongWord, varInt64] then { ... } else if vt in [varOleStr, varStrArg, varString] then { ... } else raise EVariantError.Create('Unsupported variant type'); end; |