![]() |
| ||
| Timer Control Help Hi, I am a newcomer to Visual Studio 2005 and am having trouble making a timer which will work out the time it takes to download a file. The file is 45 kb and the user can change the speed with a scrollbar, which is called hsbSpeed, from 1 – 10 kbps. The timer will then work out the download time and count down to zero. I was thinking along the line of this: Counter = (45 \ hsbSpeed.Value) - 1but it only subtracts once and stops. I tried using a loop but that also didn’t work : Counter = 45 \ hsbSpeed.ValueAny ideas on how to solve this? |
| ||
| Re: Timer Control Help I haven't done any VB coding myself, but this: Do While (Counter > 0)Looks like it will keep iterating down until the variable Counter is equal to zero, and then it will set the Text value of txtCount to 0. Try this: Do While (Counter > 0)You will probably also want to slow the loop down so that it only loops once per second. Perhaps pull the system time at the start of the loop and then wait at the end of the loop until the system time is equal to that time + 1. |
| ||
| Re: Timer Control Help Your file is 45kb and say your speed is set to 5kb. You are setting your counter to 45/5 every time. Set a variable called say "BytesLeft". After you have read 5kb subtract it from you "BytesLeft". Try something like this: Imports System.Threading |
| ||
| Re: Timer Control Help Thanks for the help guys, I had tried something similar to the code that you gave me David but it didn't work. We have to explain our coding and show the lecturer how so the code that you kindly showed me Wayne was a bit too complicated. In the end I figured out a different way to do it but thanks all the same. |
| All times are GMT -4. The time now is 5:44 pm. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC