这是一个最基本的常识问题,Case 中的条件不能是字符串,只能是有序类型,如Integer、Boolean、Char等,字符串和实型都不行的,你那个Combobox.text绝对是个字符串,行不通的,改呀:)----------------------------------
风过西窗客渡舟船无觅处
年年一川新草遥看却似旧

解决方案 »

  1.   

    看编程指南
    上面说的好好的case的条件只能是有序类型
    指针和字符串都不行
      

  2.   

    Case 中的条件不能是字符串,请用:if 语句枚举
      

  3.   

    if  edit3.Text<>''
           then
              begin
                case combobox11.Items.Index of  //报错,ordinal type required
                0:frm_rytj.ADOQuery1.SQL.Add('and 职工编号> :c');
                1:frm_rytj.ADOQuery1.SQL.Add('and 职工编号= :c');
                2:frm_rytj.ADOQuery1.SQL.Add('and 职工编号< :c');
                //报错,incompatiable type:'integer'and'string'  
                 
                frm_rytj.ADOQuery1.Parameters.ParamByName             ('c').Value:=edit3.Text;
              end;
      

  4.   

    我认为case语句是delphi的一个败笔,它不能对字符型等非顺序类型的数据进行判断,不过在现有条件下,你只好用if...else来一个一个的判断来满足条件了。
      

  5.   

    case ComboBox1.ItemIndex of
         0:frm_rytj.ADOQuery1.SQL.Add('and 职工编号> :c');
         1:frm_rytj.ADOQuery1.SQL.Add('and 职工编号= :c');
         2:frm_rytj.ADOQuery1.SQL.Add('and 职工编号< :c');
                
    ......
      

  6.   

    if  edit3.Text<>''
           then
              begin
                case combobox11.itemindex of  //报错,ordinal type required
                0:frm_rytj.ADOQuery1.SQL.Add('and 职工编号> :c');
                1:frm_rytj.ADOQuery1.SQL.Add('and 职工编号= :c');
                2:frm_rytj.ADOQuery1.SQL.Add('and 职工编号< :c');
                //报错,incompatiable type:'integer'and'string'  
                 
                frm_rytj.ADOQuery1.Parameters.ParamByName             ('c').Value:=edit3.Text;
              end;
      

  7.   

    你可以将“大于”、“等于”、“小于”这三个条件用RadioButtonGroup来实现,
    然后在Case 中可以使用
    case xxx.ItemIndex of 
      0:...;
      1:...;
      2:...;
    end;
      

  8.   

    嘻嘻,用case combobox.itemindex of 搞定
      

  9.   

    对Case只能用整型或单字符型,而不能用于字符串!