我是delphi的初学者,请各位帮忙,Tedit控件,怎样控制它的输入值,只输入数字或只输入英数字,谢谢

解决方案 »

  1.   

    procedure TForm1.Edit1KeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    begin
      if key=13 then /*相对应的ASCII码*/
        application.MessageBox('','',mb_ok);
    end;
      

  2.   

    procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
    begin
      if  not (key in ['0'..'9','a'..'z','A'..'Z',#8] )then
        key:=#0;
    end;
      

  3.   

    在EDIT的ON CHANGE事件中
    IF NOT (KEY IN['0'..'9','a'..'z','A'..'Z',#8]) THEN KEY:=#0
      

  4.   

    在EDIT的ON CHANGE事件中
    IF NOT (KEY IN['0'..'9','a'..'z','A'..'Z',#8]) THEN KEY:=#0
      

  5.   

    在EDIT的ON CHANGE事件中
    IF NOT (KEY IN['0'..'9','a'..'z','A'..'Z',#8]) THEN KEY:=#0
      

  6.   


      if  not (key in ['0'..'9','a'..'z','A'..'Z',#8] )then
        key:=#0;
      

  7.   

    在 onKeyPress事件中 只能输入数字:if  not (key in ['0'..'9',#8] )then
        key:=#0;只能输入字母
    if  not (key in [,'a'..'z','A'..'Z',#8] )then
        key:=#0;
      

  8.   

    判断数字
      if ((Key>=#48) and (Key<=#57)) or (Key='.') or (Key=#8) then
        TEdit(Sender).ReadOnly:=False
      else
        TEdit(Sender).ReadOnly:=True;
    字母类似
      

  9.   

    procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
    begin
      if  not (key in ['0'..'9','a'..'z'] )then
        key:=#0;
    end;将[]中的字符更改成你要的就可以了
      

  10.   

    请问
     if  not (key in ['0'..'9','a'..'z','A'..'Z',#8] )then小数点是用#什么代表呀?