Solved

Delphi Format to 2 decimal places

Posted on 2014-09-16
3
188 Views
Last Modified: 2014-10-30
Some of the results of this function show "9.6666666666666" and I would like that to show as "9.67".

procedure TfrmEmployeeTrainingSkill.gvDaysPerDeptTcxGridDBDataControllerTcxDataSummaryDefaultGroupSummaryItems11GetText(
  Sender: TcxDataSummaryItem; const AValue: Variant; AIsFooter: Boolean;
  var AText: string);
var FText : Extended;
begin
  inherited;
  if (AText <> NULL) AND (AText <> '') then  begin
    AText := FloatToStr((StrToFloatDef(AText,0) / 7.5 ));
    AText := AText + ' Days';
  end;
end;

Open in new window


Thanks!
0
Comment
Question by:Bianca
3 Comments
 
LVL 100

Expert Comment

by:mlmcc
ID: 40326830
Try

AText := FloatToStr((StrToFloatDef(AText,0) / 7.5 ,"0.00"));

mlmcc
0
 
LVL 26

Accepted Solution

by:
Sinisa Vuk earned 500 total points
ID: 40327450
AText := FormatFloat('0.00',  StrToFloatDef(AText,0) / 7.5)

Open in new window

0
 
LVL 14

Expert Comment

by:Pierre Cornelius
ID: 40327484
procedure TfrmEmployeeTrainingSkill.gvDaysPerDeptTcxGridDBDataControllerTcxDataSummaryDefaultGroupSummaryItems11GetText(
  Sender: TcxDataSummaryItem; const AValue: Variant; AIsFooter: Boolean;
  var AText: string);
begin
  inherited;
  if (trim(AText) <> '') 
    then  AText := FormatFloat('#,##0.00', StrToFloatDef(AText, 0) / 7.5) + ' Days'
    else AText:= '0 Days';
end;

Open in new window

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to use Hashing sha1 in Delphi 2010 4 204
TVirtualStringTree  search using TEdit 7 106
Delphi XE10 Round Image 2 79
how to update exe applicatio from internet ? 6 68
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now