procedure TForm1.Init(P: string);
begin
  case P of
    '馆长' : begin
           N2.Enabled := True;
           N3.Enabled := True;
           end;
   '验收员':N3.Enabled := True;
     end;
   end;
  [Error] : 'of'  Ordinal type required 
[Error] :
    '馆长''验收员' Incompatible types: 'Integer' and 'String'

解决方案 »

  1.   


    string和real类型不能用于case语句中
      

  2.   

    你可以转换一下:
    IF P=‘馆长' THEN P1:=1;
    IF P='验收员' THEN P1:=2;
    CASE P1 OF
    DO SOMETHING
      

  3.   

    找的 在case 语句中使用字符串
    function CaseString (const s: string; 
                         const x: array of string): Integer; 
    var i: Integer; 
    begin 
    Result:= -1; // Default return parameter 
    for i:= Low (x) to High (x) do begin 
      if s = x[i] then begin  Result:= i;  Exit;  end; 
    end; 
    end; search:= 'delphi3000'; 
    case CaseString (search, ['delphi3000', 
                               'delphipages', 
                               'Torry's']) of 
      0: s:= 'Excellent!'; 
      1: s:= 'Good source'; 
      2: s:= 'Not bad!'; 
    end; 
    ///////////////////////////////// const MatchingStrings = '*First*Second*Third*'; 
     var sString: string; 
     ...  // sString has the data you want to test 
     case pos('*'+sString+'*',MatchingStrings) of 
       1:   <do something> // This is the match for 'First' 
       7:   <do something> // This is the match for 'Second' 
       14:  <do something> // This is the match for 'Third' 
       else <do something> // In this case there were no matches 
       end;
      

  4.   

    case只能用与有序类型,如数字
      

  5.   

    lion_lh升级拉..怎么没见散分啊,keke
      

  6.   

    if p='馆长' then
       begin
               N2.Enabled := True;
               N3.Enabled := True;
       end
    else if p='验收员' then
       N3.Enabled := True
    else if ...
      

  7.   

    靠,从这一点上我觉得delphi不如VB!
      

  8.   

    case    of语句不能用string类型,太不方便啦
    我目前没发现delphi有什么优点,和VB相比