Follow up following process for making simple timer watch.....
1. Make three buttons....button1, Button2, and Button3 or any other named buttons as of your wish.
2. Make a label and rename its text to 00:00:00.00
3. To make a rectanglar shape to label use shape tools.
4. One timer control for running time.
Now for the coding......
Public Class Form1
Dim a As String
Dim b As String
Dim c As String
Dim x As String
Dim y As String
Dim z As String
Dim h As String
Dim m As String
Dim s As String
Dim u As String
Dim v As String
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
a = "0"
b = "0"
c = "0"
x = "0"
y = "0"
z = "0"
u = "0"
v = "0"
h = a + b
m = c + x
s = y + z
'To set the display as "00:00:00.00"
Label1.Text = h + ":" + m + ":" + s + "." + u + v
Timer1.Enabled = True
Timer1.Interval = 1
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Timer1.Enabled = False
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Timer1.Enabled = False
a = "0"
b = "0"
c = "0"
x = "0"
y = "0"
z = "0"
u = "0"
v = "0"
h = a + b
m = c + x
s = y + z
'To set the display as "00:00:00.00"
Label1.Text = h + ":" + m + ":" + s + "." + u + v
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
counttime()
End Sub
Sub counttime()
If Val(v) < 9 Then
v = v + 1
Label1.Text = a + b + ":" + c + x + ":" + y + z + "." + u + v
ElseIf Val(u) < 9 Then
v = 0
u = u + 1
Label1.Text = a + b + ":" + c + x + ":" + y + z + "." + u + v
ElseIf Val(z) < 9 Then
v = 0
u = 0
z = z + 1
Label1.Text = a + b + ":" + c + x + ":" + y + z + "." + u + v
ElseIf Val(y) < 5 Then
v = 0
u = 0
z = 0
y = y + 1
Label1.Text = a + b + ":" + c + x + ":" + y + z + "." + u + v
ElseIf Val(x) < 9 Then
v = 0
u = 0
z = 0
y = 0
x = x + 1
Label1.Text = a + b + ":" + c + x + ":" + y + z + "." + u + v
ElseIf Val(c) < 5 Then
v = 0
u = 0
z = 0
y = 0
x = 0
c = c + 1
Label1.Text = a + b + ":" + c + x + ":" + y + z + "." + u + v
ElseIf Val(b) < 9 Then
v = 0
u = 0
z = 0
y = 0
x = 0
c = 0
b = b + 1
Label1.Text = a + b + ":" + c + x + ":" + y + z + "." + u + v
ElseIf Val(b) < 9 Then
v = 0
u = 0
z = 0
y = 0
x = 0
c = 0
b = b + 1
Label1.Text = a + b + ":" + c + x + ":" + y + z + "." + u + v
ElseIf Val(a) < 9 Then
v = 0
u = 0
z = 0
y = 0
x = 0
c = 0
b = 0
a = a + 1
Label1.Text = a + b + ":" + c + x + ":" + y + z + "." + u + v
End If
End Sub
End Class
1. Make three buttons....button1, Button2, and Button3 or any other named buttons as of your wish.
2. Make a label and rename its text to 00:00:00.00
3. To make a rectanglar shape to label use shape tools.
4. One timer control for running time.
Now for the coding......
Public Class Form1
Dim a As String
Dim b As String
Dim c As String
Dim x As String
Dim y As String
Dim z As String
Dim h As String
Dim m As String
Dim s As String
Dim u As String
Dim v As String
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
a = "0"
b = "0"
c = "0"
x = "0"
y = "0"
z = "0"
u = "0"
v = "0"
h = a + b
m = c + x
s = y + z
'To set the display as "00:00:00.00"
Label1.Text = h + ":" + m + ":" + s + "." + u + v
Timer1.Enabled = True
Timer1.Interval = 1
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Timer1.Enabled = False
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Timer1.Enabled = False
a = "0"
b = "0"
c = "0"
x = "0"
y = "0"
z = "0"
u = "0"
v = "0"
h = a + b
m = c + x
s = y + z
'To set the display as "00:00:00.00"
Label1.Text = h + ":" + m + ":" + s + "." + u + v
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
counttime()
End Sub
Sub counttime()
If Val(v) < 9 Then
v = v + 1
Label1.Text = a + b + ":" + c + x + ":" + y + z + "." + u + v
ElseIf Val(u) < 9 Then
v = 0
u = u + 1
Label1.Text = a + b + ":" + c + x + ":" + y + z + "." + u + v
ElseIf Val(z) < 9 Then
v = 0
u = 0
z = z + 1
Label1.Text = a + b + ":" + c + x + ":" + y + z + "." + u + v
ElseIf Val(y) < 5 Then
v = 0
u = 0
z = 0
y = y + 1
Label1.Text = a + b + ":" + c + x + ":" + y + z + "." + u + v
ElseIf Val(x) < 9 Then
v = 0
u = 0
z = 0
y = 0
x = x + 1
Label1.Text = a + b + ":" + c + x + ":" + y + z + "." + u + v
ElseIf Val(c) < 5 Then
v = 0
u = 0
z = 0
y = 0
x = 0
c = c + 1
Label1.Text = a + b + ":" + c + x + ":" + y + z + "." + u + v
ElseIf Val(b) < 9 Then
v = 0
u = 0
z = 0
y = 0
x = 0
c = 0
b = b + 1
Label1.Text = a + b + ":" + c + x + ":" + y + z + "." + u + v
ElseIf Val(b) < 9 Then
v = 0
u = 0
z = 0
y = 0
x = 0
c = 0
b = b + 1
Label1.Text = a + b + ":" + c + x + ":" + y + z + "." + u + v
ElseIf Val(a) < 9 Then
v = 0
u = 0
z = 0
y = 0
x = 0
c = 0
b = 0
a = a + 1
Label1.Text = a + b + ":" + c + x + ":" + y + z + "." + u + v
End If
End Sub
End Class
Welcome
ReplyDelete