jimmy89 0 Report post Posted April 22, 2007 (edited) Hi, I'm am making this project and I need a progress bar for the status of the task. i have two values, total and total_pings which are described belowTotal > The amount that I am currently up toTotal-Pings > Total amountso, to find the work done as a percentage the code would be something like Private Sub tracker() Dim amount, final As Integer amount = total / total_pings final = amount * 100 prgStatus.Value = finalEnd Sub This would show me the percentage of work completed. But im having problems. When the program is running the progress bar doesn't change. it will sit on 0 till the 'total' value reaches 17 (half way) which then it goes to 100% and stops there.What I'm thinking thats happening is that because the values are something like 0.235... VB is rounding the values back to 0. but when it reaches half way the values becomes 0.522... and it rounds to 1, which then makes the progress bar go to 100%.My question is, how can i make VB not round the integers, or how can i complete this task with some simple code.Thanks-jimmy Edited April 22, 2007 by Jimmy89 (see edit history) Share this post Link to post Share on other sites
faulty.lee 0 Report post Posted April 22, 2007 If you look under the properties of the progress bar (prgStatus). There's 2 properties which you need to take into consideration. Maximum and Minimum. On my VS2003, the default was 100 and 0 respectively. Maximum define at what value the progress bar shows fullscale, and Minimum is the value for zero progress.If you were using the same default value, and since you multiple your amount by 100, that means it should be correct in this sense. You can try to put a break point at prgStatus.Value = final to see what value was pass over to the progress bar, or you can dump it via Debug.WriteLine. That might give you some clue as what's wrong. Share this post Link to post Share on other sites
jimmy89 0 Report post Posted April 22, 2007 the values that it's coming up with is 1 (total) and 34 (total_pings), which then it evaluates 1 / 34 as 0 and not 0.029 which is what it should be. Is there anyway to stop it rounding the values back to zero?thanks-jimmy Share this post Link to post Share on other sites
faulty.lee 0 Report post Posted April 22, 2007 the values that it's coming up with is 1 (total) and 34 (total_pings), which then it evaluates 1 / 34 as 0 and not 0.029 which is what it should be. Is there anyway to stop it rounding the values back to zero?thanks-jimmySorry, didn't notice that you declare "amount" as integer. Then try thisDim final As Integer Dim amount As Single amount = total / total_pings final = amount * 100 prgStatus.Value = final-- OR -- if you don't need the immediate variable final = total / total_pings * 100-- If you turn Strict On final = Cint(total / total_pings * 100)That should do the trick Share this post Link to post Share on other sites
jimmy89 0 Report post Posted April 22, 2007 yeah! thats worked perfectly! Thanks for your help-jimmy Share this post Link to post Share on other sites
miCRoSCoPiC^eaRthLinG 0 Report post Posted April 23, 2007 Problem solved Topic closed. Share this post Link to post Share on other sites