谢谢各位

解决方案 »

  1.   

    case要求必须是有序的类型的数据的
      

  2.   

    设置各个edit的tag值,然后利用tag值就可以用case了
      

  3.   

    不可能用CASE来判断非有序类别的数据类别
      

  4.   

    只要你的输入是整数,或者单个字符就可以用case了
      

  5.   

    同意使用 tag 不过,楼主好象不是这个意思。
      

  6.   

    可使用如下方法:
    case stringindex(edit.text,[caselist1,caselist2,caselist3]) of
      1:statement1;
      2:statement2;
      3:statement3;
    end;
    casseasd
    stringindex()函数实现如下:
    function stringindex(const searchstring:string;strlist:array of string):integer;
     var
      i:integer;
    begin
     result:=-1;
     for i:=0 to high(strlist) do
       if comparetext(searchstring,strlist[i])=0 then 
          begin
           result:=i;
           break;
          end;
    end;
      

  7.   

    caselist 是你想要判断的列表,实现的原理是用stringindex函数把你想判断的(edit.text)和一个字符串数组的值进行比较,如果相同,返回数组的序号.
    case就可以根据返回值做相应的操作了
      

  8.   

    去年程序员合订本里面专门对这个问题做了深入的讨论的不过个人认为最好的方法还是使用stringIndex
      

  9.   

    ZT:
    const
      TypeArray: array [0..3] of string =('1001A', '1001B', '1001C', '1001D');
    var
      index: integer;
    begin
      for index := Low(TypeArray) to High(TypeArray) do
        if SameText(TypeArray[index], aType) then
          Case index of
            0 : //Do Something...
            1 : //Do Something...
            2 : //Do Something...
            3 : //Do Something...
            .
            .
      

  10.   

    type
      TStringState=(s_normal,s_a,s_b);
      TArray=array[TStringState]of string;var
      arr:TArray;
      str:string;
      I:TStringState;
    begin
      str:=Edit1.Text;
      arr[s_normal]:='snormal';
      arr[s_a]:='sa';
      arr[s_b]:='sb';
      for I :=low(TStringState)  to high(TStringState)  do
      begin
        if str=arr[I] then
        case I of
          s_normal:showmessage('snormal');
          s_a:ShowMessage('sa');
          s_b:showmessage('sb');
        end;
      end;end;
      

  11.   

    设置变量,给它赋值:
    var
     i:integer;
     str:string;
    begin
      str:=edit1.Text;
      case i of
        0:str:='this is a example';
        1:str:='delphi';
      end;
    仅供参考.
      

  12.   

    或者用指针呀!case中不能用字符串判断的。