Question regarding percentage progress bar

Hi guys,
I have one simple question here.
I have a progress bar.
And I have a loop:

for(int i = 0; i<160;i++)
{
progressBar.setValue(somevalue);
}

I want to somehow connect the progress bar with this loop, so the progress bar will present the progress of the loop. For example, when i == 80, the progress bar must be 50%.
The progress bar takes INT as argument. So I can send the new value from the loop with setValue(int newValue) for example.
Can someone tell me what's the best formula to connect these two objects.

Thank you !
Look for a method called setMax() or something like that and pass it 160.

Next time make sure you mention what GUI toolkit you're using. My answer is just a guess based on the most common naming conventions.
You can also get the decimal and then multiply by 100:

1
2
3
for(int i = 0; i <= MAX; ++i) {
    progressBar.setValue((i/MAX)*100);
}
Thank you very much guys ! :)
for(int i = 0; i <= MAX; ++i) {
progressBar.setValue((i/MAX)*100);
}
This was what I needed :)
Topic archived. No new replies allowed.