怎么把EDIT中的小数转换为整数,比如EDIT.text中为'0.89',我怎么把它转为整数?

解决方案 »

  1.   

    Edit1.Text := floattostr(round(strtofloat(edit1.text)));
      

  2.   

    var t,temp:double;
    try
      temp:=strtofloat(trim(edit1.text));
    except
      ...
      exit;
    end;
    t:=round(temp);t:=trunc(temp)//四舍五入、取整。
      

  3.   

    uses maths
    ceil() 上取整
    floor()下取整
      

  4.   

    edit.text:=inttostr(round(strtoint(trim(edit.text)));//可以四舍五入
      

  5.   

    Round() 四舍五入
    Trunc() 截断
    Int()   取整数部分
      

  6.   

    edit.text:=inttostr(round(strtoint(trim(edit.text)));
      

  7.   

    str:=edit.text;
    edit.text:=copy(str,post('.',str),length(str));
      

  8.   

    edit.text:=strtoint(strtofloat(edit.text)*100);
      

  9.   

    没我的分了,就给你个留两位小数的吧,呵呵
    format('%.2f',[1234.5342])的结果是1234.53
      

  10.   

    edit.text := Int(StrToFloat(Edit.Text) * 100));
      

  11.   

    var
     P: integer;
     S: String;
    begin
      S:= Edit.Text;
      P:=Pos('.',S);
      if P <> 0 then
        Delete(S, 1, P);
      P:=StrToInt(S);//p是你想要的数值;end;