# VB help with progress bar needed



## firestormer (Sep 16, 2005)

Im learning VB so go easy.
Using VB express studio 2005 

I want to stick a progress bar on a form which basicly shows the time remaining.

The total time can be any value (within reason) and is stored in seconds as TotalTime
The time remaining is stored in seconds as TimeActualRemaining.

My proggress bar has a maximum of 1000 

I have a pre existing timer set to intervals of 100 (milliseconds)


Now i would have thought id need a calculation something like this.
1000-(1000/TotalTime)*TimeActualRemaining 
to give me the progressbars value. But when i try using it i get al sorts of errors which i think are due to it giving me decimals.

What do i need to do?


----------



## coderitr (Oct 12, 2003)

A progress bar is just that. It shows the progress of a process from the starting point to the end point. From zero percent to 100 percent. Make the minimum value 0 and and the maximum value 100. Then compute the percent complete using percent = ((elapsed time / total time) * 100) and set the value to the result of that computation. Don't over complicate.

Edit: As for the errors you're getting, see if VB 2005 still has the Fix( ) function. It truncates the decimal portion of a number. Or you can define the percent as an Integer which by definition is a whole number. The calculation should do the rounding for you.


----------

