主题:类型转换的问题EvariantTypeCastError
下面是一段记录添加的代码,我想问一下,为什么只要有一个text是空的,添加就出现错误呢,提示EvariantTypeCastError with message'Could not convert variant of type(String) into type(Double)'
procedure TtForm2.buyBut1Click(Sender: TObject);
begin
with Tb1 do
begin //添加按钮(必须每个字段都要输入)
Append;
fieldvalues['药品代码']:=buyEdit1.text;
fieldvalues['药品名称']:=buyEdit2.text;
fieldvalues['进货数量']:=buyEdit3.text;
fieldvalues['进货单价']:=buyEdit4.text;
fieldvalues['进货金额']:=buyEdit5.text;
fieldvalues['进货日期']:=buyEdit6.text;
post;
buyedit1.Text:='';
buyedit2.Text:='';
buyedit3.Text:='';
buyedit4.Text:='';
buyedit5.Text:='';
buyedit6.Text:='';
end;
end;
procedure TtForm2.buyBut1Click(Sender: TObject);
begin
with Tb1 do
begin //添加按钮(必须每个字段都要输入)
Append;
fieldvalues['药品代码']:=buyEdit1.text;
fieldvalues['药品名称']:=buyEdit2.text;
fieldvalues['进货数量']:=buyEdit3.text;
fieldvalues['进货单价']:=buyEdit4.text;
fieldvalues['进货金额']:=buyEdit5.text;
fieldvalues['进货日期']:=buyEdit6.text;
post;
buyedit1.Text:='';
buyedit2.Text:='';
buyedit3.Text:='';
buyedit4.Text:='';
buyedit5.Text:='';
buyedit6.Text:='';
end;
end;