可以用
Try
  Integer:=StrToInt(String);
Except
  On 异常事件 on   //StrToInt的异常事件我也不太清楚
    {这儿写出错代码}
end;
或者就直接用
Try
  Integer:=StrToInt(String);
Finally
  {执行完Try后,不管是否出错,都执行这儿的代码}
end;

解决方案 »

  1.   

      colacoca的方法是很好的;不过archy如果急着用的话,可以自己写函数直接判断的,很简单。
      

  2.   

    var 
      I, Code: Integer;
    begin
       Val(Edit1.Text, I, Code);  // 若成功,结果在变量 i 中;
       if (Code <> 0) and (Edit1.Text<>'') then
         MessageDlg('第' + IntToStr(Code)+'个字符出错', mtWarning, [mbOk], 0);
    end;
      

  3.   

    colacoca(可口可乐)的方法最简单和实用。具体:function IsNumber: Boolean;
    begin
      Try
        Integer:=StrToInt(String);
        Result := True;
      Except
        Result := False;
      end;  
    end;
      

  4.   

    very good!!!
    非常感谢各位,尤其是maozefa
      

  5.   

    Apollo47有一点点高深,也谢谢您!
      

  6.   

    see mine correct anwser:function isNumber(const str:string):boolean;
    var integ:integer;
    begin
      Try
        integ:=StrToInt(Str);
        //if exception then never go here');
        Result := True;
      Except
        on  e: exception do
          begin
             Result := False;
             //showmessage(e.Message);
          end;
      end;
    end;function isNumber1(const str:string):integer;
    var I, Code: Integer;
    begin
      Val(str, I, Code);  // 若成功,结果在变量 i 中;
      if (Code <> 0) and (str<>'') then
         result:=code
         //MessageDlg('第' + IntToStr(Code)+'个字符出错', mtWarning, [mbOk], 0);
      else
         result:=0 // right
    end;谢谢各位,大家交个朋友么?我在上海。oicq:944202
    colacoca(可口可乐)?  Apollo47(阿波罗) ? maozefa(之源)