短号范围

来源:互联网 发布:quick软件 编辑:程序博客网 时间:2024/06/03 14:33

tmptb.cardno表示没有的卡号

procedure TForm1.Button1Click(Sender: TObject);

var
  s:string;
  distance, poir, first,last:Integer;
begin
  Memo1.Clear;
  Memo2.Clear;
  
  qry1.Close;
  qry1.SQL.Text :='select * from tmptb where cardno>0 order by cardno asc ';
  qry1.Open;


  qry1.First;
  first := qry1.fieldbyname('cardno').AsInteger;
  qry1.Next;


  distance:=0;
  poir := first;
  while not qry1.Eof  do
  begin
   last :=qry1.fieldbyname('cardno').AsInteger;


   if poir+1=last then
   begin
    Inc(distance,+1);


    poir := last;
   end
   else  //重新定义开始和结束
   begin    //last已经是断开,范围应该是从first到poir
     if distance>=100 then
     begin
      // s:='从'+inttostr(first)+'-->'+inttostr(poir);
      // Memo1.Lines.Append(s);
       Memo1.Lines.Append(inttostr(first));
       Memo2.Lines.Append(inttostr(poir));
     end;
     first:= last;
     poir := first;
     distance :=0;
   end;




   qry1.Next;
  end;
end;
0 0
原创粉丝点击