数据t1,与下表
  t_doll       t_zhk
    a1          b1
    a2          b2
    a3          b3
    a4          b4
    a5          b5
    a6          b6
    a7          b7
    a8          b8
中字段t_doll中的值比较,如果t1介于a(i)与a(i+1)之间,就取t2=b(i);搞半天没搞定!晕!请各位大虾给出原码!

解决方案 »

  1.   

    不是呀!是按条件取字段t_zhk中的值呀,没高收押?
      

  2.   

    把下表的数据都放到tstrings中去处理
      

  3.   

    把下表的数据都放到tstrings中去处理?怎么处理
      

  4.   

    不知道你是什么数据库
    假如两个字段是一一对应而且顺序不会改变的话,可以在程序中实现如下处理
    //将数据读到TSTRINGS中
    var
      sl1,sl2: TStrings;
      t1,t2,iValue: Double;//要比较的数值,不知道你比较的数值是什么类型的
      i: integer;
    begin
      sl1 := TStringList.Create;
      sl2 := TStringList.Create;
      iValue := t1;//给iValue赋值 
      with ADOQuery do  //ADOQuery的数据为下表内容,将两个字段分别保存到TStrings中去
      begin
        First;
        While not Eof do
        begin
          sl1.Add(FieldbyName('t_doll').AsString);
          sl2.Add((FieldbyName('t_zhk').AsString);
          Next;
        end;
        for i:=0 to Recordcount - 1 do
        begin
          if (iValue >= strtofloat(sl1.strings[i])) and (iValue <= strtofloat(sl1.strings)[i+1])  then t2 := sl2.strings[i];
        end;
      end;
      sl1.Free;
      sl2.Free;
    end;
    //假如不是一一对应的,那要分开处理
      

  5.   

    lzy6204(为了忘却的记忆) 牛!到
    http://community.csdn.net/Expert/topic/3679/3679404.xml?temp=.1765406
    来接分!