views:

138

answers:

1

Hello,

It seems trivial, but I cant find a clean algorithm to this.

I can calculate my total rows to 2186.

Then I thought I do a 2186 / 100 = 21 (which would be my modNr) Then I thought I would increment the currentRowNr++ inside Backgroundworker.reportprocess() And do a if(currentRowNr % modNr == 0) increment progressbar.

The progress bar now seems to behave correctly however, it doesnt stop at 100. I get an expection that the number went over maximal of 100. My algorithm seems wrong.

There must be a clean solution for this and I am just making it overcomplicated. Anyone good in math? ;-)

Thank you

+3  A: 

Set the Maximum property of the progessbar to 2186 and Minimum property to 0. Now every time you got past a single item in your processing you increase the value of the progressbar by 1. Removes the need for an algorithm at all since the progessbar will take care of that for you.

Qua
actually, I'm thinking this IS an algorithm
Muad'Dib
Not really, you're just taking advantage of the fact that the progessbar already comes with an algorithm to take care of the issue. I suppose you could call set of instruction for an algorithm though.
Qua