if not (Key in ['M','F']) then
    Key:=#0;这样不成,为什么?

解决方案 »

  1.   


    key:word;是个整数的
    if KEY=77 or Key=77 then
        Key:=#0;
      

  2.   

    怎么不成,这样可以,如果要小写也可以,就设置
    edit的charcase属性。修改一下集合就行了。
      

  3.   

    是不是你写代码的事件不对,试试下面的,我试过了,可以procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
    begin
      if (key<>'M') and (key<>'F') then
        key:=#0;
    end;
      

  4.   

    if not (Key in ['M','F']) then //这样写输入M或是F全不没用。
        Key:=#0; if KEY=77 or Key=77 then //是什么意思?
      

  5.   

    可以的
    你要在ONKEYPRESS事件里呀!!!!
      

  6.   

    procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
    begin
     if not ((key='F') or (key='M')) then
         key:=#0;
    end;