Currency Problems 
Author Message
 Currency Problems

I have written a program and need to add to Amount together depending on the
hours eg
var price,Total:real;

Jobprice.caption:="1,250.00"
TotalJobpeice.caption:="0.00"
TotalHours.text:="4";

    t:=strtoint(TotalHours.text);
   st:=JobPrice.text;
   Delete(st,1,1);  { this bit remove the symbol }
   val(st,Price,err);
   Total:=0.00;
   for i:=0 to t do Total:=Total+Price;
   str(total:12:2,st);
   TotalJobPrice.text:=st;

when i run it the value of price=2 and not 1,250.00 * 4
Can anyone please help me

Thank You
Steve



Wed, 18 Jun 1902 08:00:00 GMT  
 Currency Problems


Quote:
> I have written a program and need to add to Amount together depending on
the
> hours eg
> var price,Total:real;

> Jobprice.caption:="1,250.00"
> TotalJobpeice.caption:="0.00"
> TotalHours.text:="4";

>     t:=strtoint(TotalHours.text);
>    st:=JobPrice.text;
>    Delete(st,1,1);  { this bit remove the symbol }
>    val(st,Price,err);
>    Total:=0.00;
>    for i:=0 to t do Total:=Total+Price;
>    str(total:12:2,st);
>    TotalJobPrice.text:=st;

> when i run it the value of price=2 and not 1,250.00 * 4
> Can anyone please help me

uummm - if JobPrice.Caption = "1,250.00", then why is st = JobPrice.text,
not JobPrice.caption???

HTH

Karl



Wed, 18 Jun 1902 08:00:00 GMT  
 Currency Problems


Quote:
> I have written a program and need to add to Amount together depending on
the
> hours eg
> var price,Total:real;

> Jobprice.caption:="1,250.00"
> TotalJobpeice.caption:="0.00"
> TotalHours.text:="4";

>     t:=strtoint(TotalHours.text);
>    st:=JobPrice.text;
>    Delete(st,1,1);  { this bit remove the symbol }
>    val(st,Price,err);

As usual, Delphi makes no errors. At this point, price contains 1 (the first
1 in the field) and  err contains 2 (the first non numeric character).

As much as possible, you should use text fields only to display numeric
values, and assign numeric variables to store and manipulate your numeric
data.

var totPrice : Currency;
      totHours : Integer;

Hours.Caption := IntTosStr(totHours);

etc.

Also, try to forget some of the Turbo Pascal coding and code in Delphi.

Quote:
>    Total:=0.00;
>    for i:=0 to t do Total:=Total+Price;
>    str(total:12:2,st);
>    TotalJobPrice.text:=st;

> when i run it the value of price=2 and not 1,250.00 * 4
> Can anyone please help me

> Thank You
> Steve




Wed, 18 Jun 1902 08:00:00 GMT  
 Currency Problems
Thank very All
I spoke to Karl and now it work's a treat i have now added the following:
i still had to delete the and the , but it works fine
thank you again
Steve

     t:=strtoint(TotalHours.text);
     st:=JobPrice.text;
     if st[1]='' then Delete(st,1,1);
     for i:=0 to Length(st) do if st[i]=',' then delete(st,i,1);
     Price:=StrToCurr(st);
     Total:=0;
     for i:=1 to t do Total:=Total+Price;
     st:=CurrToStr(Total);
     TotalJobPrice.text:=st;


Quote:



> > I have written a program and need to add to Amount together depending on
> the
> > hours eg
> > var price,Total:real;

> > Jobprice.caption:="1,250.00"
> > TotalJobpeice.caption:="0.00"
> > TotalHours.text:="4";

> >     t:=strtoint(TotalHours.text);
> >    st:=JobPrice.text;
> >    Delete(st,1,1);  { this bit remove the symbol }
> >    val(st,Price,err);

> As usual, Delphi makes no errors. At this point, price contains 1 (the
first
> 1 in the field) and  err contains 2 (the first non numeric character).

> As much as possible, you should use text fields only to display numeric
> values, and assign numeric variables to store and manipulate your numeric
> data.

> var totPrice : Currency;
>       totHours : Integer;

> Hours.Caption := IntTosStr(totHours);

> etc.

> Also, try to forget some of the Turbo Pascal coding and code in Delphi.

> >    Total:=0.00;
> >    for i:=0 to t do Total:=Total+Price;
> >    str(total:12:2,st);
> >    TotalJobPrice.text:=st;

> > when i run it the value of price=2 and not 1,250.00 * 4
> > Can anyone please help me

> > Thank You
> > Steve




Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. EURO, Dual currency problems

2. Currency Problem with Delphi

3. problem with Access Currency Field

4. Currency format problem

5. Problem: Change Currency to Euro?

6. AddFieldDef - (currency) Decimal point problem

7. Currency field display format

8. Euro currency symbol ...

9. Alternative for currency field

10. Currency Fields

11. How to get REAL numbers in DBGRid to show like currency

12. Currency Field lossing precision

 

 
Powered by phpBB® Forum Software