Bustin Jieber
Bustin Jieber

Reputation: 111

Progressbar rounding to nearest integer - VB.NET

I am having an issue with progress bars and can't seem to get them to show decimal values such as 0.5 or 4.1. When i set them as values with decimals it says "Property value is not valid". It further says that "2.5 is not a valid value for Int32". Can't seem to find any solutions on these forums or anywhere else on the internet.

Thanks

EDIT : So there is no way for me to assign decimal values in a progress bar?

Upvotes: 2

Views: 749

Answers (3)

Matt Wilko
Matt Wilko

Reputation: 27342

You have to specify the value as an Integer. So if you want to show 0-100% with 0.1% increments you can just scale everything up by 10:

ProgressBar1.Max = 1000

Then scale up the value by a factor of 10. So to show 4.1%:

ProgressBar1.Value = CInt(4.1 * 10)

If you want to have another digit of precision you could scale up further.

Upvotes: 2

sujith karivelil
sujith karivelil

Reputation: 29026

The .Value property of the ProgressBar class is Defined as integer, so you cannot assign decimal values to it.

<BindableAttribute(True)> _
Public Property Value As Integer

If you want to show the progress percentage in decimal format, then you can place a label over it and print the value in that label.

Upvotes: 0

Alessandro Mandelli
Alessandro Mandelli

Reputation: 581

Can't use decimals in a progress bar. I suggest you to multiply your value x10 times and set 5 for 0.5 and 41 for 4.1

Upvotes: 2

Related Questions