by The Mafia (2 Submissions)
Category: Miscellaneous
Compatability: Visual Basic 4.0 (32-bit)
Difficulty: Unknown Difficulty
Originally Published: Wed 10th September 2003
Date Added: Mon 8th February 2021
Rating: (1 Votes)
Stopclock with a Hand. uses a Shape, a Line, a Timer and 3 Command Buttons
API Declarations
'a Shape
'a Line
'a Timer
'3 Command buttons
'Place them Anywhere on the form
Dim a As Double
Dim b As Integer
Dim c As Integer
Dim sec As Long
Dim min As Long
Dim hrs As Long
Timer1.Enabled = True
End Sub
Private Sub Command2_Click()
Timer1.Enabled = False
End Sub
Private Sub Command3_Click()
Unload Me
Load Me
End Sub
Private Sub Form_Load()
Command1.Caption = "&Start" 'Buttons
Command2.Caption = "S&top"
Command3.Caption = "&Reset"
Command1.Move 940, 300, 1000, 350
Command2.Move 2100, 300, 1000, 350
Command3.Move 3255, 300, 1000, 350
Line1.X1 = 3000 'Line
Line1.Y1 = 3000
Timer1.Interval = 1000 'Timer
Timer1.Enabled = False
Shape1.Move 2900, 2900, 200, 200 'Shape
Shape1.Shape = 2
Shape1.BackStyle = 1
Shape1.BackColor = vbBlack
Shape1.BorderColor = vbBlack
Me.Move 500, 500, 6000, 6000 'Form
Me.AutoRedraw = True
Me.DrawWidth = 2
Me.Show
For a = 0 To 3.14159 * 2 Step (3.14159 * 2) / 60 '60 secs in a minute
b = (Sin(a) * 2100) + 3000
c = (Cos(a) * 2100) + 3000
PSet (b, c)
Next a
a = ((3.14159 * 2) / 60) * 44 '44 secs
sec = -1
Call Timer1_Timer
End Sub
Private Sub Timer1_Timer()
a = a + ((3.14159 * 2) / 60) '60 secs in a minute
b = (Cos(a) * 2000) + 3000
c = (Sin(a) * 2000) + 3000
Line1.X2 = b
Line1.Y2 = c
If a >= (3.14159 * 2) Then a = 0
sec = sec + 1
If sec = 60 Then
sec = 0
min = min + 1
If min = 60 Then
min = 0
hrs = hrs + 1
If hrs = 24 Then
hrs = 0
End If
End If
End If
Me.Caption = hrs & ": " & min & ": " & sec
End Sub
No comments have been posted about Stopclock with a Hand. uses a Shape, a Line, a Timer and 3 Command Buttons. Why not be the first to post a comment about Stopclock with a Hand. uses a Shape, a Line, a Timer and 3 Command Buttons.