Reputation: 97
I've got a program that's got some variables. I'm trying to interact the variables and make them show a visual perspective of time by using them to increment the progress bar.
A rendition of the code:
Dim count As Integer = ListBox1.Items.Count
Dim _toProgress As Integer = 100 / count
ProgressBar1.Increment(_toProgress)
I've got this all in a loop, so "_toProgress" is added on after a process (in a loop) has been completed...
That's basically the code I have simplified. The problem is that when I increment the progress bar, it finished before it's supposed to.
e.g: I've got a loop completing 175 process: 100 / 175 = 0.5714285714285714 So, _toProgress should equal '0.5714285714285714'. Once one of the processes has been completed, it adds '_toProgress' to the incrementation (ProgressBar1.Increment(_toProgress)).
I know the '_toProgress' integer is correct, because '0.5714285714285714' * 175 = 100.
So I have no clue why the progress bar completes before it's supposed to, any clues?
Upvotes: 0
Views: 1142
Reputation: 44931
You can only increment a ProgressBar in Integer increments.
The easiest solution is to change the Maximum
property of the ProgressBar to the number of processes that you have and then increment by 1.
For example:
ProgressBar1.Maximum = ListBox1.Items.Count
ProgressBar1.Increment(1)
Upvotes: 4