为什么progressbar 进度条满了程序还没完?
当ListBox1.Items.Count数在100-200还看不出来,当最大数在2000就发现进度条已走完,程序还没完.为什么?
代码如下pb1(progressbar ):
pb1.Min:=0;
pb1.Max:=ListBox1.Items.Count;
pb1.Position:=0;for I := 0 to ListBox1.Items.Count-1 do    // Iterate
begin
pb1.Position:=pb1.Position+i;
end;

解决方案 »

  1.   

    也就是说,如果for 循环计划要运算2000次,但只走到200次时进度条就已经满了
      

  2.   

    pb1.Min      :=0;
    pb1.Max      :=ListBox1.Items.Count;
    pb1.Position :=0;for I := 0 to ListBox1.Items.Count-1 do    // Iterate
    begin
      pb1.Position := pb1.Position + pb1.Max Div (ListBox1.Items.Count + 1);
      /加1为了防止出现除数为0
    end;
      

  3.   


    for I := 0 to ListBox1.Items.Count-1 do    // Iterate 
    begin 
    pb1.Position:=pb1.Position+i
    end;
    里面应该是+1 吧? 
      

  4.   


    for I := 0 to ListBox1.Items.Count-1 do begin 
    pb1.Position:=pb1.Position+1; 
    end;
      

  5.   

    最终结果是:pb1.Min      :=0; 
    pb1.Max      :=100; 
    pb1.Position :=0; for I := 0 to ListBox1.Items.Count-1 do    // Iterate 
    begin 
      pb1.Position := pb1.Position + pb1.Max Div (ListBox1.Items.Count - 1); end;