谢谢

解决方案 »

  1.   

    onkeypress事件处理if key not in['a'..'z'] Then
    begin
     showmessage('not a-z');
     key=#0;
    end;
      

  2.   

    刚才是我没说清楚,对不起!
    a:='b'
    如何判断a这个变量的值在26个字母之间?
    我使用if not (a in['a'..'z']) then 结果出错
      

  3.   

    if not(Ord(Key) in [Ord('a')..Ord('z')]) then
      

  4.   

    ['a'..'z']都是char型的如果a是string型的,一定出错!
      

  5.   

    //  if (Ord('a') in [Ord('a')..Ord('z')]) then
        if ('a' in ['a'..'z']) then      //都可以---------------------------------------------------
    你的:
    如何判断a这个变量的值在26个字母之间?
    我使用if not (a in['a'..'z']) then 结果出错//a不是字符,所以出错
      

  6.   

    下面这段代码,你看如何:
    function comparestr (str: string): boolean;
      var
        i: integer;
        strtem: string;
    begin
      result:= false;
      strtem:= '';
      for i:= 0 to length(str) do
        begin
          strtem:=str[i];
          if (strtem[i]>='a')and(strtem[i]<='z') then
                begin
                  result:= true;
                  exit;
                end;
       end;
    end;
    procedure TForm1.Button2Click(Sender: TObject);
    begin
      if comparestr(edit1.Text)and(length(edit1.Text)<2) then
           showmessage('该值在26个字母之间')
      else
        if length(edit1.Text)>2 then
             showmessage('只能输入一个值');
    end;