![]() |
| ||
| restricting decimal places on floating point values hi, just a quick question can somebody please tell me how to restrict the output of the code below to 2 decimal places. VolumeCalc.Caption := FloatToStr(StrToFloat(EngineSizeVal.Text) / 2 / StrToFloat(CylNumVal.Text)); thx for the help. |
| ||
| Re: restricting decimal places on floating point values Use the Format command like this: VolumeCalc.Caption := Format('%.2f',[StrToFloat(EngineSizeVal.Text) / 2 / StrToFloat(CylNumVal.Text)]);Sub Xero |
| ||
| Re: restricting decimal places on floating point values thx for the help works great! |
| ||
| Re: restricting decimal places on floating point values i have just changed my Label to a EditBox.. and the above code doesnt seem to work at all, just wondering how to limit an edit box to 2 decimal places. VolumeCalc.Text := FloatToStr(StrToFloat(EngineSizeVal.Text) / 2 / StrToFloat(CylNumVal.Text)); |
| ||
| Re: restricting decimal places on floating point values It should be exactly the same. Format returns a string, so there's no difference in applying the result to an Editbox or a label. What exactly is the problem? Sub Xero |
| ||
| Re: restricting decimal places on floating point values dont matter, had a bit too much to drink last night :/ format is working fine, sorry about wasting your time asking again. thx for the help |
| All times are GMT -4. The time now is 12:43 pm. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC