?
Solved

Delphi Format to 2 decimal places

Posted on 2014-09-16
3
Medium Priority
?
226 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 101

Expert Comment

by:mlmcc
ID: 40326830
Try

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

mlmcc
0
 
LVL 27

Accepted Solution

by:
Sinisa Vuk earned 2000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

764 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