在edit的onexit或onchange事件中判断 select name from 表 where name='''+edit1.text+''''; if 有记录 then edit3.text:=帐户资金减去总价
在edit2的changed事件中if trim(edit1.text) <> '' then begin adoquery1.sql.text:= 'select 总价 from 表1 where 姓名 = '''+trim(edit1.text)+''''; adoquery1.active:= true; if not adoquery1.eof then edit3.text:= floattostr(adoquery1.fields[0].asfloat - strtofloat(edit2.text)) else showmessage('error! no record found!'); end;
如果想要即时的,就在onchanged事件中处理 其他的也可以回车后处理
兄弟。提示这个错误信息:incompatible types:'integer' and 'string'
select name from 表 where name='''+edit1.text+'''';
if 有记录 then
edit3.text:=帐户资金减去总价
begin
adoquery1.sql.text:= 'select 总价 from 表1 where 姓名 = '''+trim(edit1.text)+'''';
adoquery1.active:= true;
if not adoquery1.eof then
edit3.text:= floattostr(adoquery1.fields[0].asfloat - strtofloat(edit2.text))
else showmessage('error! no record found!');
end;
其他的也可以回车后处理
兄弟。提示这个错误信息:incompatible types:'integer' and 'string'
很明显的错误提示,数值类型转换错误,edit3.text是字符型的,看看哪里被转成integer了
别什么事情都来提问,这样效率更低