try 
  strtoint(edit1.text);//strtofloat()
except
  showmessage('not integer');
end;

解决方案 »

  1.   

    To Naughtyboy:
    编译产生错误!
      

  2.   

    使用
    SetWindowLong(Edit1.Handle, GWL_STYLE,
                      GetWindowLong(Edit1.Handle, GWL_STYLE) or
                      ES_NUMBER); 使edit只能输入数字,无需判断
      

  3.   

    上面的程序会在IDE环境下报错的。也可以通过键值判断procedure TFrom1.edt1Press(Sender: TObject; var Key: Char);
    begin
      if not ((key >= '0') and (key <= '9')) then
        if ((key <> '.') and (key <> #8)) or
          ((key = '.') and (pos('.', Trim(edt1.text)) > 0)) then
          key := #0;
    end;
      

  4.   

    To TIAN:
    你的方法太棒.可我不会api,你可否详悉些?谢谢!
      

  5.   

    try
      strtoint(edit1.text);
    except
      showmessage('数据转换错误!');
      abort;
    end;