如何将Edit1中的文本内容(小数点后所有的数字的舍去即取整)
代码应如何写?

解决方案 »

  1.   

    procedure TForm1.Button1Click(Sender: TObject);
    var
      tp:String;
      I:Integer;
      R:Integer;
    begin
      tp:=Edit1.Text;
      I:=Pos('.',tp);
      If I>0 then
        R:=StrToInt(Copy(tp,1,I-1))
      Else
        R:=StrToInt(tp);
    end;
      

  2.   

    procedure TForm1.Button1Click(Sender: TObject);
    var
      tp:String;
      I:Integer;
      R:Integer;
    begin
      tp:=Edit1.Text;
      R := Trunc(StoToFloat(tp));
    end;