title: VB.net real-time time elapsed feature
body: <p>I already have created a real time clock that synchronizes with the computer time and is being displayed in a label.</p>
  
  <pre><code>Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
      Timer1.Enabled = True
  End Sub
  
  Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
      Time.Text = Date.Now.ToString("h:mm:ss tt")
  End Sub
  </code></pre>
  
  <p>I want to make a real-time time elapsed feature that keeps on counting the seconds/minutes/hours elapsed from the time it started till the time it stops and it would be basing on the real-time clock i have created. I would be creating a start and stop button for this. Is this possible? Thanks in advance. </p>
  
  <hr>
  
  <p>I am now able to complete everything and i added a feature that records the starting and ending time based on my real time clock. Here is my working code:</p>
  
  <pre><code>Dim hr, min, sec As Integer
  
  Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
      Timer1.Enabled = True
  End Sub
  
  Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
      Time.Text = Date.Now.ToString("h:mm:ss tt")
  End Sub
  
  Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
  
      Start.Text = ""
      EndLbl.Text = ""
      Elapse.Text = ""
      Timer2.Enabled = True
      Start.Text = Time.Text
  End Sub
  
  Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
  
      sec = sec + 1
      If (sec = 60) Then
          sec = 0
          min = min + 1
      ElseIf (min = 60) Then
          min = 0
          hr = hr + 1
      ElseIf (hr = 24) Then
          hr = 0
          min = 0
          sec = 0
      End If
  
      Elapse.Text = String.Format("{0}hr : {1}min : {2}sec", hr, min, sec)
      Timer2.Interval = 1000
  End Sub
  
  Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
      Timer2.Enabled = False
      EndLbl.Text = Label4.Text
  
      hr = 0
      min = 0
      sec = 0
      Timer2.Interval = 1
  End Sub
  </code></pre>
  
  <p>Credits to the starting code given by NeverHopeless. Thanks alot.</p>