How To Make A Stopwatch In VB.NET

Today i am going to teach you how to make a stopwatch in visual basic 2008/ visual basic 2010 the features are start, stop, mark and reset this is not a advanced stopwatch, but this has the basic features of a stopwatch probably this is for beginners so lets get started with opening your visual basic 2008 / visual basic 2010

1 . Create a new project
2 . Add a label, 4 buttons, 1 listbox and a timer
3 . Go to timer properties and change timer interval to 1 
4 . I recommend you to arrange your tools like this

5 . Time for coding double click form and add all these codes
Public Class Form1

    'Author : Mohamed Shimran
    'Blog : http://www.ultimateprogrammingtutorials.blogspot.com

    Dim StopWatch As New Diagnostics.Stopwatch
    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Dim elapsed As TimeSpan = Me.StopWatch.Elapsed
        Label1.Text = String.Format("{0:00}:{1:00}:{2:00}:{3:00}", Math.Floor(elapsed.TotalHours), elapsed.Minutes, elapsed.Seconds, elapsed.Milliseconds)
    End Sub
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Timer1.Start()
        Me.StopWatch.Start()
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Timer1.Stop()
        Me.StopWatch.Stop()
    End Sub

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        Me.StopWatch.Reset()
        Label1.Text = "00:00:00:000"
        ListBox1.Items.Clear()
    End Sub

    Private Sub Button3_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
      ListBox1.Items.Add(Label1.Text)
    End Sub
End Class  
6 . Now debug the program and the program would work like this


Hope you enjoyed the tutorial.