这样的数字处理怎么写一个LISTBOX1的内容是00001到99999所有5位的数字,所有数字都是五位,比如
00001
00003
00004
00007
00008
00009
00010
00012
等等....按button1后快速找出listbox1中不存在的数字,然后显示在listbox2里,比如
00002
00005
00006
00011
00013
等等....

解决方案 »

  1.   

    如果李叔同波形中的数据是顺序的,那就好办,溜一遍就够了,如果是无序的,你就需要循环一个区间的数据,然后在listbox1中查找是否有(indexof),如果没有就添加到listbox2
      

  2.   

    如果listbox1中的数据是顺序的,那就好办,溜一遍就够了,如果是无序的,你就需要循环一个区间的数据,然后在listbox1中查找是否有(indexof),如果没有就添加到listbox2
      

  3.   

    首先列举出所有满足条件的五位数,然后逐个判断listbox1是否有,没有添加到listbox2中,不过速度肯定不会快了
      

  4.   

    楼上正解。
    咋n多帖子都是结帖率低下的id在问问题呢?
      

  5.   

    遍历:procedure TForm1.Button1Click(Sender: TObject);
    var
      iLoop  : Integer;
      sValue : String;
    begin
      for iLoop := 1 to 99999 do
      begin
        sValue := Format('%.5d', [iLoop]);
        if ListBox1.Items.IndexOf(sValue) < 0 then ListBox2.Items.Add(svalue);
      end;
    end;
      

  6.   


    var
      i:integer;
      str:string;
    begin
      for i := 1 to 10000 do  //范围自己定
      begin
        str := Format('%.5d',[i]);//前补0,总长度5
        if ListBox1.Items.IndexOf(str) < 0 then
          ListBox2.Items.Add(str)
      end;
    end;
      

  7.   

    var
      intI: Integer;
      strList: TStringList;
      strList2: TStringList;
      strList3: TStringList;
    begin
      strList2:= TStringList.Create;
      //--测试数据
      strList:= TStringList.Create;
      for intI:= 1 to 99 do
      begin
        strList.Add(format('%0.5d',[intI]));
      end;  for intI:= 103 to 999 do
      begin
        strList.Add(format('%0.5d',[intI]));
      end;
      //--测试数据
      strList3:= TStringList.Create;
      strList3.Assign(strList);
      for intI:= 1 to 99999 do
      begin
        if (strList3.Count<intI) or (strList3.Strings[intI-1]<>format('%0.5d',[intI])) then
        begin
          strList2.Add(format('%0.5d',[intI]));
          strList3.Insert(intI-1,format('%0.5d',[intI]));
        end;
      end;  listbox1.Items.Assign(strList2);  strList3.Free;
      strList.Free;
      strList2.Free;
    end;
      

  8.   

    伪代码如下:for BaseNumber:=1 to 99999 do
    begin
      //首先把1等数字转换为00001的格式
      s := formatFloat('00000',BaseNumber);
      if ListBox1.Items.IndexOf(s)=-1 then addToListBox2;
    end;