by Vice Roy (1 Submission)
Category: Miscellaneous
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Thu 13th March 2003
Date Added: Mon 8th February 2021
Rating:
(1 Votes)
Analog Clock Created By viceroy
'Get time and draw 3 index step by step
Private Sub Run(O As Object)
Const PI As Single = 3.1415
Dim NewTime As Single
Dim GocH As Single, GocM As Single, GocS As Single
Dim H As Single, M As Single, S As Single
Dim r As Single
NewTime = Time
H = Hour(NewTime)
M = Minute(NewTime)
S = Second(NewTime)
GocH = PI * ((H Mod 12) / 6 + M / 360 + S / 4320)
GocM = PI * (M / 30 + S / 1800)
GocS = PI * ((Timer + 1.7) / 30)
O.Cls
If (O.ScaleHeight < O.ScaleWidth) Then r = O.ScaleHeight / 2 Else r = O.ScaleWidth / 2
VeKim O, 3.5 * r / 5, GocH, vbBlue, 6 'Kim gio:Hour index
VeKim O, 5 * r / 6, GocM, vbDesktop, 3 'Kim phut:Min index
VeKim O, r, GocS, vbRed, 1 'Kim giay: Sec index
VeKim O, r / 6, PI + GocS, vbRed, 2 'Duoi kim giay: Tag of Sec index
Me.Caption = Time
End Sub
'Draw index
Private Sub VeKim(O As Object, r As Single, Goc As Single, Mau As Long, Size As Single)
Dim Xo As Single, Yo As Single, X As Single, Y As Single
Xo = O.ScaleWidth / 2
Yo = O.ScaleHeight / 2
X = Xo + r * Sin(Goc)
Y = Yo - r * Cos(Goc)
O.ForeColor = Mau
O.DrawWidth = Size
O.Line (Xo, Yo)-(X, Y)
End Sub
Private Sub Form_Resize()
Run Me
End Sub
Private Sub Timer1_Timer()
Run Me
End Sub