你可以使用MaskEdit控件,将editmask属性设为!9999999999;1; 就可以了。

解决方案 »

  1.   

    你有edit的onkeypress事件中这样写
    if not(key int['0'..'9','.']) then 
     key=chr(0)
    else
    //在这加上你的处理语句即可
      

  2.   

    刚才回复时的
    应为key:=chr(0);
    给分吧,一定行啊
      

  3.   

    你是在KEYDOWN里面检查扫描码吗?肯定是不同的,不然系统怎么区分是小键盘还是数字键的输入?
    用VK系列的虚拟键值应该不会有问题的。
      

  4.   

    在edit1exit事件中
    if edit1.text<>'' then
    begin
      try
        strtoint(edit1.text);
      except
        showmessage('格式错误');
      end;
    end;
      

  5.   

    onkeypress
    if not(key in [#48..#57]) then key:=#0;