paulpitchford
Member
- Joined
- Jul 6, 2006
- Messages
- 5
- Programming Experience
- 3-5
Hi,
Thanks to another thread on this site I have found some code to countdown from a set period of time:
What I am now looking for is some code that starts at 0:00:00 and increments like a stopwatch second by second (0:00:01... 0:00:02 and so on)
Any help would be appreciated. I'm farily new to VB.NET so go easy on me!
Thanks in advance.
Kind Regards,
Paul Pitchford.
Thanks to another thread on this site I have found some code to countdown from a set period of time:
VB.NET:
[SIZE=2][COLOR=#0000ff]Private[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=2] Timer1_Tick([/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] sender [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.Object, [/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] e [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.EventArgs) [/SIZE][SIZE=2][COLOR=#0000ff]Handles[/COLOR][/SIZE][SIZE=2] Timer1.Tick[/SIZE]
[SIZE=2]
[/SIZE][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][SIZE=2] alarmTime < [/SIZE][SIZE=2][COLOR=#0000ff]Date[/COLOR][/SIZE][SIZE=2].Now [/SIZE][SIZE=2][COLOR=#0000ff]Then
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff] Me[/COLOR][/SIZE][SIZE=2].Timer1.Stop()
MessageBox.Show([/SIZE][SIZE=2][COLOR=#800000]"Time's up."[/COLOR][/SIZE][SIZE=2])
[/SIZE][SIZE=2][COLOR=#0000ff]Else
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff] Dim[/COLOR][/SIZE][SIZE=2] remainingTime [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] TimeSpan = [/SIZE][SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].alarmTime.Subtract([/SIZE][SIZE=2][COLOR=#0000ff]Date[/COLOR][/SIZE][SIZE=2].Now)
[/SIZE][SIZE=2][COLOR=#0000ff] Me[/COLOR][/SIZE][SIZE=2].Label1.Text = [/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][SIZE=2].Format([/SIZE][SIZE=2][COLOR=#800000]"{0}:{1:d2}:{2:d2}"[/COLOR][/SIZE][SIZE=2], _
remainingTime.Hours, _
remainingTime.Minutes, _
remainingTime.Seconds)
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub
[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#008000]'Then in the command button code[/COLOR][/SIZE][/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2][COLOR=#000000].alarmTime = [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Date[/COLOR][/SIZE][SIZE=2][COLOR=#000000].Now.AddMinutes(30)[/COLOR]
[/SIZE][/COLOR][/SIZE][/SIZE]
What I am now looking for is some code that starts at 0:00:00 and increments like a stopwatch second by second (0:00:01... 0:00:02 and so on)
Any help would be appreciated. I'm farily new to VB.NET so go easy on me!
Thanks in advance.
Kind Regards,
Paul Pitchford.