Option Explicit On 

Public Class frmStopWatch
  Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

  Public Sub New()
    MyBase.New()

    'This call is required by the Windows Form Designer.
    InitializeComponent()

    'Add any initialization after the InitializeComponent() call

  End Sub

  'Form overrides dispose to clean up the component list.
  Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
    If disposing Then
      If Not (components Is Nothing) Then
        components.Dispose()
      End If
    End If
    MyBase.Dispose(disposing)
  End Sub
  Friend WithEvents Button1 As System.Windows.Forms.Button
  Friend WithEvents Button2 As System.Windows.Forms.Button
  Friend WithEvents Button3 As System.Windows.Forms.Button
  Friend WithEvents Label1 As System.Windows.Forms.Label
  Friend WithEvents Label2 As System.Windows.Forms.Label
  Friend WithEvents Label3 As System.Windows.Forms.Label
  Friend WithEvents btnEnd As System.Windows.Forms.Button
  Friend WithEvents btnExit As System.Windows.Forms.Button
  Friend WithEvents lblStart As System.Windows.Forms.Label
  Friend WithEvents lblEnd As System.Windows.Forms.Label
  Friend WithEvents lblElapsed As System.Windows.Forms.Label
  Friend WithEvents btnStart As System.Windows.Forms.Button
  Friend WithEvents Label4 As System.Windows.Forms.Label
  Friend WithEvents Label5 As System.Windows.Forms.Label
  Friend WithEvents Label6 As System.Windows.Forms.Label

  'Required by the Windows Form Designer
  Private components As System.ComponentModel.Container

  'NOTE: The following procedure is required by the Windows Form Designer
  'It can be modified using the Windows Form Designer.  
  'Do not modify it using the code editor.
  <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
    Me.Label1 = New System.Windows.Forms.Label()
    Me.Label2 = New System.Windows.Forms.Label()
    Me.Label3 = New System.Windows.Forms.Label()
    Me.btnEnd = New System.Windows.Forms.Button()
    Me.lblElapsed = New System.Windows.Forms.Label()
    Me.btnExit = New System.Windows.Forms.Button()
    Me.lblStart = New System.Windows.Forms.Label()
    Me.btnStart = New System.Windows.Forms.Button()
    Me.lblEnd = New System.Windows.Forms.Label()
    Me.SuspendLayout()
    '
    'Label1
    '
    Me.Label1.Location = New System.Drawing.Point(120, 8)
    Me.Label1.Name = "Label1"
    Me.Label1.TabIndex = 1
    Me.Label1.Text = "Start Time"
    '
    'Label2
    '
    Me.Label2.Location = New System.Drawing.Point(120, 40)
    Me.Label2.Name = "Label2"
    Me.Label2.TabIndex = 1
    Me.Label2.Text = "End Time"
    '
    'Label3
    '
    Me.Label3.Location = New System.Drawing.Point(120, 72)
    Me.Label3.Name = "Label3"
    Me.Label3.Size = New System.Drawing.Size(104, 23)
    Me.Label3.TabIndex = 1
    Me.Label3.Text = "Elapsed Time (sec)"
    '
    'btnEnd
    '
    Me.btnEnd.Location = New System.Drawing.Point(8, 40)
    Me.btnEnd.Name = "btnEnd"
    Me.btnEnd.Size = New System.Drawing.Size(104, 23)
    Me.btnEnd.TabIndex = 0
    Me.btnEnd.Text = "&End Timing"
    '
    'lblElapsed
    '
    Me.lblElapsed.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
    Me.lblElapsed.Location = New System.Drawing.Point(240, 72)
    Me.lblElapsed.Name = "lblElapsed"
    Me.lblElapsed.TabIndex = 1
    '
    'btnExit
    '
    Me.btnExit.Location = New System.Drawing.Point(8, 72)
    Me.btnExit.Name = "btnExit"
    Me.btnExit.Size = New System.Drawing.Size(104, 23)
    Me.btnExit.TabIndex = 0
    Me.btnExit.Text = "E&xit"
    '
    'lblStart
    '
    Me.lblStart.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
    Me.lblStart.Location = New System.Drawing.Point(240, 8)
    Me.lblStart.Name = "lblStart"
    Me.lblStart.TabIndex = 1
    '
    'btnStart
    '
    Me.btnStart.Location = New System.Drawing.Point(8, 8)
    Me.btnStart.Name = "btnStart"
    Me.btnStart.Size = New System.Drawing.Size(104, 23)
    Me.btnStart.TabIndex = 0
    Me.btnStart.Text = "&Start Timing"
    '
    'lblEnd
    '
    Me.lblEnd.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
    Me.lblEnd.Location = New System.Drawing.Point(240, 40)
    Me.lblEnd.Name = "lblEnd"
    Me.lblEnd.TabIndex = 1
    '
    'frmStopWatch
    '
    Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
    Me.ClientSize = New System.Drawing.Size(354, 111)
    Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.lblEnd, Me.lblElapsed, Me.lblStart, Me.Label3, Me.Label2, Me.Label1, Me.btnExit, Me.btnEnd, Me.btnStart})
    Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle
    Me.Name = "frmStopWatch"
    Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
    Me.Text = "Stopwatch Application"
    Me.ResumeLayout(False)

  End Sub

#End Region

  Dim StartTime As Date
  Dim EndTime As Date
  Dim ElapsedTime As Integer

  Private Sub btnStart_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnStart.Click
    'Establish and print starting time
    StartTime = Now
    lblStart.Text = Format(StartTime, "hh:mm:ss")
    lblEnd.Text = ""
    lblElapsed.Text = ""
  End Sub

  Private Sub btnEnd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEnd.Click
    'Find the ending time, compute the elapsed time
    'Put both values in lable boxes
    EndTime = Now
    ElapsedTime = DateDiff(DateInterval.Second, StartTime, EndTime)
    lblEnd.Text = Format(EndTime, "hh:mm:ss")
    lblElapsed.Text = Format(ElapsedTime, "0")
  End Sub

  Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
    Me.Close()
  End Sub
End Class
