Solved

Delphi Format to 2 decimal places

Posted on 2014-09-16
3
217 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 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
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…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

707 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