How to create a stopwatch? Not using labels.
Hi, I was just wondering if there was anyway to create some sort of stopwatch, that doesnt include labels signifing, milli seconds etc?
Thanks
BleepyE
Junior Poster in Training
87 posts since Dec 2010
Reputation Points: 10
Solved Threads: 0
Welcome BleepyE.
Read the forum rules. You need to show effort, and what better way than posting the code that you have tried so far?
Homework policy
__avd
Posting Genius (adatapost)
8,648 posts since Oct 2008
Reputation Points: 2,136
Solved Threads: 1,241
__avd
Posting Genius (adatapost)
8,648 posts since Oct 2008
Reputation Points: 2,136
Solved Threads: 1,241
Sorry was on my phone when I created this thread.
Current code consists of adding 1 to a value of a label ever timer tick.
Pritty basic stuff.
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
timer1.start()
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
If Label1.Text = 10 Then
Label2.Text += 1
Label1.Text = 0
Else
Label1.Text += 1
End If
End Sub
End Class
Id really prefer a method of accuratly timing something, like a stopwatch, but not using labels.
Something that I would develop into a application that recorded times.
Thanks
BleepyE
Junior Poster in Training
87 posts since Dec 2010
Reputation Points: 10
Solved Threads: 0
@Santyfurtado
I do believe that code is C not VB.net
Thanks anyway
BleepyE
Junior Poster in Training
87 posts since Dec 2010
Reputation Points: 10
Solved Threads: 0
@ange_tb
Thanks, im getting there.
I found this on the web which is closer to what im after.
Public Class Form1
Dim Time As New DateTime 'This will just create a DateTime Element
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If Timer1.Enabled = True Then
Timer1.Stop() 'Yea....Stops if it was started
Else
Time = DateTime.Now 'This will change 'Time' to the current time
Timer1.Start() 'Starts the Timer.
End If
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Dim Difference As TimeSpan = DateTime.Now.Subtract(Time) 'This is really what the entire application runs off of. It will take 'Time' Witch is set to the time that the button was clicked at and subtract it from the current time
Label1.Text = Difference.Days.ToString & ":" & Difference.Hours.ToString & ":" & Difference.Minutes.ToString & ":" & Difference.Seconds.ToString & "." & Difference.Milliseconds.ToString 'This line...Will just make it so we can read it. Days:Hours:Minutes:Seconds.Milliseconds
End Sub
End Class
Its quite nice
Thanks to reconrey1292
BleepyE
Junior Poster in Training
87 posts since Dec 2010
Reputation Points: 10
Solved Threads: 0