Source Code : Advance Stopwatch
Stopwatch in vb.net
(Screen Shot)
******************************************
Public Class Form1
Dim Time As New DateTime
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Button4.Visible = False
Button5.Visible = False
Button6.Visible = False
Label2.Visible = False
Label3.Visible = False
Label4.Visible = False
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If Timer1.Enabled = True Then
Timer1.Stop()
Else
Time = DateTime.Now
Timer1.Start()
Button4.Visible = True
Button5.Visible = True
Button6.Visible = True
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)
Label1.Text = Difference.Hours.ToString & ":" & Difference.Minutes.ToString & ":" & Difference.Seconds.ToString & ":" & Difference.Milliseconds.ToString
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Timer1.Stop()
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Label1.Text = "00:00:000"
Label2.Text = "00:00:000"
Label3.Text = "00:00:000"
Label4.Text = "00:00:000"
Label2.Visible = False
Label3.Visible = False
Label4.Visible = False
Button4.Enabled = True
Button4.Visible = False
Button5.Enabled = True
Button5.Visible = False
Button6.Enabled = True
Button6.Visible = False
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Label2.Visible = True
Label2.Text = Label1.Text.Trim
Button4.Enabled = False
End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
Label3.Visible = True
Label3.Text = Label1.Text.Trim
Button5.Enabled = False
End Sub
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
Label4.Visible = True
Label4.Text = Label1.Text.Trim
Button6.Enabled = False
End Sub
End Class
(Screen Shot)
******************************************
Public Class Form1
Dim Time As New DateTime
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Button4.Visible = False
Button5.Visible = False
Button6.Visible = False
Label2.Visible = False
Label3.Visible = False
Label4.Visible = False
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If Timer1.Enabled = True Then
Timer1.Stop()
Else
Time = DateTime.Now
Timer1.Start()
Button4.Visible = True
Button5.Visible = True
Button6.Visible = True
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)
Label1.Text = Difference.Hours.ToString & ":" & Difference.Minutes.ToString & ":" & Difference.Seconds.ToString & ":" & Difference.Milliseconds.ToString
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Timer1.Stop()
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Label1.Text = "00:00:000"
Label2.Text = "00:00:000"
Label3.Text = "00:00:000"
Label4.Text = "00:00:000"
Label2.Visible = False
Label3.Visible = False
Label4.Visible = False
Button4.Enabled = True
Button4.Visible = False
Button5.Enabled = True
Button5.Visible = False
Button6.Enabled = True
Button6.Visible = False
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Label2.Visible = True
Label2.Text = Label1.Text.Trim
Button4.Enabled = False
End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
Label3.Visible = True
Label3.Text = Label1.Text.Trim
Button5.Enabled = False
End Sub
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
Label4.Visible = True
Label4.Text = Label1.Text.Trim
Button6.Enabled = False
End Sub
End Class
************** End Project **************************
Comments
Post a Comment