Solved

Delphi Format to 2 decimal places

Posted on 2014-09-16
3
182 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
Comment Utility
Try

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

mlmcc
0
 
LVL 25

Accepted Solution

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

Open in new window

0
 
LVL 14

Expert Comment

by:Pierre Cornelius
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

771 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

10 Experts available now in Live!

Get 1:1 Help Now