Fórum somar valores #401127
16/05/2011
0
if Edit2.Text <> '' then
begin
DBEdit1.Text := (ADOTable1.FieldByName('E1').AsInteger) + strtofloat(edit2.Text);
end
else
Edit2.Text := '0';
DBEdit1.Text := (ADOTable1.FieldByName('E1').AsInteger) + strtofloat(edit2.Text);Daniel
Curtir tópico
+ 0Posts
16/05/2011
Eliel Martins
O que está ocorrendo esse erro, é que você está tentando passar uma soma de dois valores, sendo um do tipo Integer e outro Float para uma propriedade Text que é string, você precisa converte essa soma para passar para um tipo String, segue o exemplo abaixo :
DBEdit1.Text := StrtoFloat((ADOTable1.FieldByName('E1').AsInteger) + strtofloat(edit2.Text));
Observação : Verifica se está correto, você está somando um valor inteiro com um valor float.
Espero ter ajudado .
Eliel G. Martins
Gostei + 0
16/05/2011
Emerson Nascimento
DBEdit1.Field.AsFloat := ADOTable1.FieldByName('E1').AsInteger + strtofloat(edit2.Text);
ou
DBEdit1.Field.AsInteger := ADOTable1.FieldByName('E1').AsInteger + strtointdef(edit2.Text,0);
Gostei + 0
16/05/2011
Marco Salles
va tem que fazer a conversão Inversa ....
var
V:integer;
begin
V:=StrtoIntDef(Edit2.Text,0);
DBEdit1.Text := intToStr(ADOTable1.FieldByName('E1').AsInteger) + V);
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)