What does mean VarType(aVariant) = 273
(or $111)? It's undocumented variant type. VarTypeAsText(aVariant)
returns Expression illegal in evaluator
error.
Asked
Active
Viewed 2,423 times
4

Dmitry
- 14,306
- 23
- 105
- 189
2 Answers
4
From the source code of the system unit:
const
{ Variant type codes (wtypes.h) }
varEmpty = $0000; { vt_empty 0 }
varNull = $0001; { vt_null 1 }
varSmallint = $0002; { vt_i2 2 }
varInteger = $0003; { vt_i4 3 }
varSingle = $0004; { vt_r4 4 }
varDouble = $0005; { vt_r8 5 }
varCurrency = $0006; { vt_cy 6 }
varDate = $0007; { vt_date 7 }
varOleStr = $0008; { vt_bstr 8 }
varDispatch = $0009; { vt_dispatch 9 }
varError = $000A; { vt_error 10 }
varBoolean = $000B; { vt_bool 11 }
varVariant = $000C; { vt_variant 12 }
varUnknown = $000D; { vt_unknown 13 }
//varDecimal = $000E; { vt_decimal 14 } {UNSUPPORTED as of v6.x code base}
//varUndef0F = $000F; { undefined 15 } {UNSUPPORTED per Microsoft}
varShortInt = $0010; { vt_i1 16 }
varByte = $0011; { vt_ui1 17 }
varWord = $0012; { vt_ui2 18 }
varLongWord = $0013; { vt_ui4 19 }
varInt64 = $0014; { vt_i8 20 }
varUInt64 = $0015; { vt_ui8 21 }
varRecord = $0024; { VT_RECORD 36 }
{ if adding new items, update Variants' varLast, BaseTypeMap and OpTypeMap }
varStrArg = $0048; { vt_clsid 72 }
varObject = $0049; { 73 }
varUStrArg = $004A; { 74 }
varString = $0100; { Pascal string 256 } {not OLE compatible }
varAny = $0101; { Corba any 257 } {not OLE compatible }
varUString = $0102; { Unicode string 258 } {not OLE compatible }
// custom types range from $110 (272) to $7FF (2047)
See the comment at the very bottom of the list. In other words, $111
is a custom variant type. Exactly what it is depends on the code that defined that type. Code that is not in the RTL and is presumably in your program.

David Heffernan
- 601,492
- 42
- 1,072
- 1,490
-
Thanks. But I have no code to manage variants. It's a value of TADODataSet floating field. – Dmitry Jul 14 '14 at 07:20
-
It might not be code that you've written personally, but it's code in your app. Search for `$0111` – David Heffernan Jul 14 '14 at 07:32
-
If it's in a TADODataSet field then it depends on the underlying field type of the DBMS. – Stefan Glienke Jul 14 '14 at 07:38
2
The $0111
or 273
is a custom variant type knows as VarFMTBcd
present in unit Data.FmtBcd
(or FmtBcd
for old Delphi versions).
You can force (if you want) a conversion to a single type like this:
PS: It´s just a example, that is, verification of proof of use.
function GetValue<T>(const AValue: TField): T;
var
Value : TValue;
begin
try
Value := TValue.FromVariant(AValue.AsVariant);
except
on E:EVariantTypeCastError do
begin
if (TVarData(AValue.AsVariant).VType = VarFMTBcd) then
Value := TValue.FromVariant(AValue.AsExtended)
else
raise;
end;
end;
Result := Value.AsType<T>;
end;
Use:
var
Price : Currency;
begin
Price := GetValue<Currency>(Query.FieldByName('Price'));
end;

dipold
- 787
- 8
- 18