那当我往Tedit控件中输入信息进去的时候我怎么判断我输入的是数字还是字符啊?

解决方案 »

  1.   

    可以在OnKeyDown事件中限定只能输入字符或数字。
      

  2.   

    if not (key in['0'..'9']) then
      key:=#0在KeyPress里写
      

  3.   

    以上控制只能写数字!字母是['a'..'z','A'..'Z']
      

  4.   

    //判断刚输入的一个字符是数字还是字母
    procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
    begin
      if key in ['0'..'9'] then
      Caption:='数字哦!';
      if key in ['a'..'z','A'..'Z'] then
      Caption:='字母哦!'
    end;
      

  5.   

    procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
    begin
      if  not (key in ['0'..'9','.',#13,#8]) then  key:=#0
    //只能用数字,".",回车(#13),退格(#8)
    end;
      

  6.   

    if not key in  ['a'..'z','A'..'Z',#8] then do somethings
      

  7.   

    procedure xxxxKeyPress(Sender: TObject; var Key: Char);
    begin
      if not (Key in ['0'..'9', #3, #22, #24, #8, #9, #13, #46]) then
        Key := #0;
    end;可以输入数字,CTRL+C/V/X,以及小数点,ENTER 和backspace我也是学来的,谢谢那位大虾。