现有str:='12345.56' 想格式化成:12,345.56

解决方案 »

  1.   

    查看下Format 函数帮助,里边有这样的Format('%n',[12345.56]);
      

  2.   


    修改一下.....
    小数点后面保存几位小数,你就写几个#。
    formatfloat('#,#.##',12345.56);
      

  3.   

    小数点后面保存几位小数,你就写几个#。formatfloat('#,#.##',12345);   //12,345formatfloat('#,#.##',12345.56);//12,345.56对于整数的处理是一样的通用的。下面来自delphi的帮助文档的内容:function FormatFloat(const Format: string; Value: Extended): string; overload;
    function FormatFloat(const Format: string; Value: Extended; const FormatSettings: TFormatSettings): string; overload;The following table shows some sample formats and the results produced when the formats are applied to different values:Format string- 1234 -1234 0.5 0
    1234 -1234 0.5 0
    0 1234 -1234 1 0
    0.00  1234.00 -1234.00 0.50 0.00
    #.##   1234 -1234 .5
    #,##0.00 1,234.00 -1,234.00 0.50 0.00
    #,##0.00;(#,##0.00) 1,234.00 (1,234.00) 0.50 0.00
    #,##0.00;;Zero  1,234.00 -1,234.00 0.50 Zero
    0.000E+00    1.234E+03 -1.234E+03 5.000E-01 0.000E+00
    #.###E-0   1.234E3 -1.234E3 5E-1 0E0