Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   Varios (https://www.clubdelphi.com/foros/forumdisplay.php?f=11)
-   -   formula.. (https://www.clubdelphi.com/foros/showthread.php?t=39464)

truequeman 20-01-2007 12:43:46

formula..
 
hola. necesito una formula para un descuento lo he intentado pero no se por que me sale mal... la cosa es que cuando marca mas de 1,000 (con coma) todo sale mal... pero cuando la cantidad es menor a 999 si saca los descuentos

estoy haciendo esto:

if Descuento.Text <> '0' then
begin
If Length(Descuento.Text) = 1 then
Dsto := StrToFloat('0.0' + Descuento.Text)
else
Dsto := StrToFloat('0.' + Descuento.Text);
ActAReal := '';
for K:=1 to Length(SubTotal.Text) do
begin
If SubTotal.Text[K] in ['0'..'9','.'] then
ActAReal := ActAReal + SubTotal.Text[K]
end;
SubTotal.Text := ActAReal;
Stal := StrToFloat(SubTotal.Text) * Dsto;
SubTotal.Text := FloatToStrF(StrToFloat(Subtotal.Text) - Stal , FFNumber, 9,2);
end;

si alguien sabe una forma mejor o solucionar esto espero me respondan.saludos.

Onti 20-01-2007 16:31:12

Por que no utilizas los componentes RXLib, con el CurrencyEdit puedes trabajar con valores numéricos directamente.

Por ejemplo:
Código Delphi [-]
  E_Total.Value :=E_Precio.value-(E_Precio.value*(E_Descuento.value/100));

truequeman 20-01-2007 17:52:47

evento
 
en el evento key press puse :
(de cada descuento)


procedure TVentArt.Descuento2KeyPress(Sender: TObject; var Key: Char);
var
desc2,total,totaldescontado: real;
begin
If Key = #13 then
begin
Cerrar.SetFocus;
Descuento2.SetFocus;
total:=strtofloat(totventa.text);
desc2:=((strtofloat(descuento2.text))/100) + 1;
totaldescontado:=(total/ desc2);
totventa.Text:=floattostrF((totaldescontado),FFNumber,9,2);
end
else
If Key = #27 then
Descuento2.Clear
else
begin
if not (Key in ['0'..'9',#8]) then
Key := #0;
end;
end;

pero cuando la cantidad tiene un "," se pone loca la suma.

Lepe 20-01-2007 19:12:09

Por favor, edita tu mensaje y añade las etiquetas delphi, te quedará un mensaje más profesional ;).

Saludos


La franja horaria es GMT +2. Ahora son las 18:53:20.

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