try
  strtoint(edit1.text) 
except
  on E:exception  do
     showMessage(E.message);
end;

解决方案 »

  1.   

    if ch in ['a'..'z','A'..'Z'] then
      字符
    else
      数字
      

  2.   

    大概有两种方法:
    1、 如上说的try... except 的结构
    2。在edit1的OnKeyPress事件中写代码
     if key in ['0','1','2','3','4','5','6','7','8','9'] then 
     else Abort
      

  3.   

    这样吧,在form的public里设两个boolean型变量,IsChar和IsInt;
    在Edit 的keypress里
    IsChar:=false;
    IsInt:=false;
    if (key in  ['a'..'z'])or(key in ['A'..'Z']) then IsChar:=true;
    if (key in[0..9])then IsInt:=true;
    然后在需要的地方再判断这两个变量的值就行了.;
      

  4.   

    if key in ['0','1','2','3','4','5','6','7','8','9'] then IsInt:=true;
     else IsInt:=false;
      

  5.   

    if (edit1.text>='000000000000000000000') and (edit1.text>='9999999999999999999')
      

  6.   

    TheTop(黄河上游) 的有道理!也可行!
      

  7.   

    if key in ['0','1','2','3','4','5','6','7','8','9','.'] then IsInt:=true;
     else IsInt:=false;不遥忘了小数点  13.5也是数字哦
      

  8.   

    上面的全部都是蠢猪:
    if IsNumeric(char(edit1.text)) then 
      showmessage('非字符串');
    else showmessage('字符串');
      

  9.   

    由于erp2(天涯劍) 说话太不礼貌少加一点分
      

  10.   

    不错,天涯剑果然比上面的人聪明一点,不过也够蠢的了。
    标准方法是用val,你可以在程序里写个val,在上面按F1看delphi的帮助,很详细的,还有例子。