Delphi/Formatfloat

Advertisement


Question
Hi Brian,
As a follow up on the RtoC function you kindly provided - it works fine in limiting the decimal places but it puts in a thousands seperator when the number exceeds 999.  This is something that I don't want to happen.  Can this be fixed?

Regards
Michael

Answer
Michael,
The original message indicated that you wanted the thousands seperator:
Edit1.text:=Formatfloat('#,##0.00',mydouble);

If you don't want the thousands seperators, then you have to change the function.
I've got a different function for that (RtoS instead of RtoC).

function  RtoS(Source: Double; S,D: integer): string;
Var TStr: string;
begin
 TStr:=Format('%'+IntToStr(S)+'.'+IntToStr(D)+'f',[Source]);
 RtoS:= TStr;
end;


The only thing different is the name of the function, and the type specifier ('f' instead of 'n')
Sincerely,
Brian

Delphi

All Answers


Answers by Expert:


Ask Experts

Volunteer


Brian Sill

Expertise

Designing and implementing DOS, DPMI, and Windows apps in TP, BP, and Delphi (Windows VCL, Custom Controls, Runtime UI design, Windows API, Database, SQL, Threading, Btrieve, Pervasive.SQL, Advantage Database, ADO to MDB, ADO to MS SQL, MDI Apps, MS Office Integration, barcode generation, Document imaging application development, TIFF file structure, and some IFF file experience).

Experience

Turbo Pascal and Delphi developer since 1986. Proficient in web design incuding XHTML, CSS, and Javascript. Fluent in C, C++, Visual Basic (especially VBA), and Modula-2.

Education/Credentials
Over 20 years designing and implementing DOS, DPMI, and Windows apps in TP, BP, and Delphi.

©2016 About.com. All rights reserved.