用Val函数判断或用try strToint()except end;

解决方案 »

  1.   

    在onkeypress事件中输入
    if not (key in  ['0'..'9',#8]) then  key:=#0;
      

  2.   

    在文本框中找到其onkeypress 的方法,例如下面的edit例子procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
    begin
    if (key>'A')  and (key<'z') then
       key:=chr(0);
    end;
      

  3.   

    在onkeypress事件中输入
    if not (key in  ['0'..'9',#8]) then  key:=#0;
      

  4.   

    类似的问题不是前面有很多嘛,
    在KeyPress 事件中处理
      if not (key in  数字 then  key:=#0;
      

  5.   

    也可这样:
    在keypress事件中:
    try
      i:=strtoint(edit1.text);
    except
      abort;
    end;