在keypress里面写:
   if not key in ['0','1','2','3','4','5','6','7','8','9'] then
   begin
     beep;
     key:=0;
   end;

解决方案 »

  1.   

    procedure...
    begin
      if not(key in  [0..9]) then
       key:=#0;
    end
      

  2.   

    请问ihihonline(小小)   key:=#0;一句中的#号是什么作用?谢谢。
      

  3.   

    key:=#0,
    好象是说:将ASCII为0的字符赋给Key
      

  4.   

    if not (Key in ['0'..'9']) then
      key:=#0;
      

  5.   

    更正;
    procedure...
    begin
      if not(key in  ['0'..'9']) then
       key:=#0;
    end
    不好意思;
      

  6.   

    “#”表示数值在0..255之间数字的相应的AscII码值,#是一个控制字符;
    例如:'You'可以表示成#89#111#117
    showmessage(#89#111#117)等价于showmessage('You')