# How to create a decrease in progressBar?

Hello! I have this problem
I have a timer and progress bar ( as like life ) )

and I need if the timer is already more than say 15 seconds then the progress bar will start 1 unit decrease

but I get that it is reduced only 1 time and all
``````for (int i = 0; i < 1; i++)
{
progressBar2.Value = 100;
progressBar2.Maximum = 100;
progressBar2.Minimum = 0;

progressBar2.Value = progressBar2.Value--;
}``````

Given the fact that this code is in Timer Tick with chastotoy 1000
April 19th 20 at 12:04
April 19th 20 at 12:06
Solution
``````for (int i = 0; i < 1; i++)
{
progressBar2.Value = 100;
progressBar2.Maximum = 100;
progressBar2.Minimum = 0;

progressBar2.Value = progressBar2.Value--;
}``````

And the cycle how many times do you work out? M?
Every time you set the progress value to 100 (progressBar2.Value = 100;)
Why do you even loop here? Why are you setting the progress value to 100 every tick of the timer?

Really hard to think about what happens if you have everything written?
1. Set progress bar to 100, the border of the progress bar to 0 and 100. (Progress bar = 100)
2. Decrement the position by 1 (Progress bar = 99)
--tick
3. Set progress bar to 100, the border of the progress bar to 0 and 100. (Progress bar = 100)
4. Decrement the position by 1 (Progress bar = 99)
--tick
5. Set progress bar to 100, the border of the progress bar to 0 and 100. (Progress bar = 100)
6. Decrement the position by 1 (Progress bar = 99)
--tick
7. Set progress bar to 100, the border of the progress bar to 0 and 100. (Progress bar = 100)
8. Decrement the position by 1 (Progress bar = 99)
the situation has not changed even when rendered outside of the loop the maximum \ value \ at least progress -_- - Nicholas_Halvorson71 commented on April 19th 20 at 12:09
@Nicholas_Halvorson71, carefully read the answer - lindsay61 commented on April 19th 20 at 12:12
@Nicholas_Halvorson71, every time You set the progress value to 100 (progressBar2.Value = 100;)
Why do you even loop here? Why are you setting the progress value to 100 every tick of the timer? - lindsay61 commented on April 19th 20 at 12:15
even right now, put it in a simple condition (value--) not in the cycle but the timer frequency 1000
the same thing - Nicholas_Halvorson71 commented on April 19th 20 at 12:18
@lindsay61, All on**** carried out cycle and the timer , and the timer remains only the condition (ZST--)
and still nothing has changed ! can email as it has my head no th not cooking today.... - Nicholas_Halvorson71 commented on April 19th 20 at 12:21
To timer
``````progressBar2.Value = 100;
progressBar2.Maximum = 100;
progressBar2.Minimum = 0;``````

Inside the timer
`progressBar2.Value--;`
or
`progressBar2.Value = progressBar2.Value - 1;` - lindsay61 commented on April 19th 20 at 12:24
@lindsay61, LOLLLL so stupid -_- that means not sleeping until 6 in the morning ) - Nicholas_Halvorson71 commented on April 19th 20 at 12:27
April 19th 20 at 12:08
Solution
``````progressBar2.Value = 100;
progressBar2.Maximum = 100;
progressBar2.Minimum = 0;
for (int i = 0; i < 1; i++)
progressBar2.Value--;``````

Find more questions by tags C#