Solved

Delphi Format to 2 decimal places

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

809 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