Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   OOP (https://www.clubdelphi.com/foros/forumdisplay.php?f=5)
-   -   Error de Currency (https://www.clubdelphi.com/foros/showthread.php?t=27964)

Epunamun 05-12-2005 22:45:56

Error de Currency
 
Estoy manejando valores de monedas y nesecito hacer calculos y me sale error, de tipos ejemplo


Código:

var
a: Currency;
a1: Currency;
tot: Currency;
begin
a := strtoint(dbedit1.Text);  //precio compra
a1 := strtoint(maskedit1.Text); //valor del cliente
tot := (a * a1);
maskedit2.Text := inttostr(tot);

Esto va a un procedimiento ayuda plz

marcoszorrilla 05-12-2005 22:59:42

Prueba así:

Código Delphi [-]
  procedure TForm1.Button1Click(Sender: TObject);
  var
  a  : Currency;
  a1 : Currency;
  tot: Currency;
  begin
  a  := strtoint(edit1.Text);  //precio compra
  a1 := strtoint(maskedit1.Text); //valor del cliente
  tot:= (a * a1);
  maskedit1.Text := FormatFloat(',0.00',tot);
  end;

Además deberías utilizar Try...Except para cubrirte de valores incorrectos.

Un Saludo.

Epunamun 05-12-2005 23:41:25

muchas gracias te pasaste


La franja horaria es GMT +2. Ahora son las 19:44:45.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi