打不到VarAsType的解决办法

来源:互联网 发布:python还是c 编辑:程序博客网 时间:2024/04/29 21:33

在uses单元加入Variants!

VarType function from Variants unit in Delphi 7

In Delphi 5, VarType function is declared in Systems unit.  In Delphi 7, it is moved to Variants unit.
Declaration: property Values[const name: String]: Variant
My problem is the statement Values['fieldname']:= 0 gives problem and the statement Values['fieldname']:= StrToInt('0') seems to work.  
The field in the table is an integer field.  
The same thing happens with a float field, the statement Values['fieldname']:= 1 gives problem and the statement Values['fieldname']:= StrToFloat('1') seems to work.  
Does the Variant need to be "informed" what datatype it is with the help of functions like StrToInt and StrToFloat?
原创粉丝点击