a := 00000.0;
b := 12.0;
c := a+ b;
Edit2.Text := Format('%0.5f', [c])

解决方案 »

  1.   

    FormatFloat('00000',a+b); // a,b可以是整数 返回 '00012';
      

  2.   

    没闹明白你的意思。
    1.‘00000’和‘12’是两个串,怎么加?你的程序却是'0'+'12',那当然是012啦!
    2.你是否要将结果变成等长的串,不足位补0?如果是这样,那当然是
    S := IntToStr(Trunc(StrToFloat(R1) + StrToFloat(R2)));
    S := Copy(S, Length(S) - 4, 5);
      

  3.   

    你这两句
    S := IntToStr(Trunc(StrToFloat(R1) + StrToFloat(R2)));
    S := Copy(S, Length(S) - 4, 5);
    根本不能实现"不足位补0"的功能
      

  4.   

    用 case ... of end; 进行判断不够六位在前面加'0'补位
      

  5.   

    procedure TForm1.Button1Click(Sender: TObject); 
    var 
    a,b:real; //a,b:string;
    c:string; 
    begin 
    a:=00000; '//'00000'
    b:=12; //'12';
    c:=FloatToStr(a)+FloatToStr(b); //c:=a+b;
    Edit2.Text:=c; 
    end; 
    但得出的结果是:012,而不是00012。如何修改上面的语句呢?