例如:
将数字全部保留三为小数怎么样搞才好啊?
12.4 -->   12.400
0    -->   0.000
10   -->   10.000

解决方案 »

  1.   

    procedure TForm1.Button1Click(Sender: TObject);
    var
      f : single;
    begin
      f := 12.4;
      showmessage(format('%10.3f',[f]));
      f := 0;
      showmessage(format('%10.3f',[f]));
    end;
      

  2.   

    对,楼上的真星星多,format(),查一下帮助,会有很多有关的操作,
      

  3.   

    你可以用函数formatfloat('0.000',num);
    num可是你说的那些数字
      

  4.   

    对了  这个函数返回的是string
    function FormatFloat(const Format: string; Value: Extended): string;
    Description
    FormatFloat formats the floating-point value given by Value using the format string given by Format. The following format specifiers are supported in the format string:
      

  5.   

    可以用FormatFloat('0.000',0)   ->    0.000
    FormatFloat('#.###',0)     ->    0
    可以查阅这个主题的帮助
      

  6.   

    都说了我就不说了。没事时看看有关delphi的函数集,很基础的问题。
      

  7.   

    也可以通过双击ADOQuery1后,选想要格式化的字段属性来Format: #.###
      

  8.   

    FloatToStrF(Number,ffNumber,整数位,小数位)
      

  9.   

    把Number改成你的数字就可以用了
      

  10.   

    showmessage(formatfloat('0.000',12.3))