Can anyone help me out with this I am in the process of jumping from VB6 to VB.Net 2005 B2.
I can't seem to be able to get this coded properly. I want to have a simple label that will increment time from the moment I press a "Start" button until the moment I press a "Stop" button. The time would be in the following format hh:mm:ss

Keeping Track of Time?
Bullfrog
jetsetwilly
Private pausing As Boolean
Private totalPauseSpan As TimeSpan
Private pauseBegun As DateTime
Then, when the Pause button is clicked, if pausing is False, I set pauseBegun to "Now", pausing to True, and Timer1.Enabled to False.
Then the Pause button is clicked and pausing is True, I check how long the pause has been, add that TimeSpan to the totalPauseSpan variable, set pausing to False and start the Timer again.
For the totalPauseSpan to have an impact on your Label, I just edit the "Dim span ..." line to this:
Dim span As TimeSpan = (DateTime.Now - start) - totalPauseSpan
Complete code (now with milliseconds for more bells and whistles - set the Timer1.Interval to a small value...):
Stefan de Vogelaere
I'm not completely sure of what your intent is here. The totalPauseSpan variable keeps track of the total paused time span - i.e. the part of the measured time that should not be included.
However, if you want to start the timer at a certain value when clicking "Start", you could set the totalPausSpan variable to a negative value to start with. Add the following line to your StartButton_Click event and see what happens:
totalPauseSpan = New
TimeSpan(-3, -10, -15)dana_lotus
DanSequel
Add a DateTime object to your form.
Then add code to the Button's Click event and the Timer's Tick event:
Yiannis Piros
One last quick question on this code...
How can I set the "pauseSpan" to be something like, 3 hours, 21 minutes and 32 seconds or something... have it start at a certain time
Thank you VERY much in advance.