gravatar

Jam Analog


'Buat Form dan 1 Timer




Option Explicit
Dim xgen, ygen, xmin, ymin, xsec, ysec, xhor, yhor As Double
Dim h, m, s As Date
'control the minute '
Function mint()
If s >= 0 And s < 12 Then
    Call findminangle(CDbl(m))
ElseIf s >= 12 And s < 24 Then
    Call findminangle(CDbl(m) + 0.2)
ElseIf s >= 24 And s < 36 Then
    Call findminangle(CDbl(m) + 0.4)
ElseIf s >= 36 And s <= 48 Then
    Call findminangle(CDbl(m) + 0.6)
ElseIf s >= 48 And s <= 59 Then
    Call findminangle(CDbl(m) + 0.8)
End If
xmin = xgen
ymin = ygen
Line (Form1.ScaleWidth / 2, Form1.ScaleHeight / 2)-(xmin, ymin), RGB(255, 24, 32)
End Function
'control the second
Function secnd()
    Call findminangle(CDbl(s))
    xsec = xgen
    ysec = ygen
    Line (Form1.ScaleWidth / 2, Form1.ScaleHeight / 2)-(xsec, ysec), RGB(100, 100, 100)
  
End Function
'control the hour
Function hr()
  
    If m >= 0 And m < 12 Then
        Call findminangle(CDbl(h) * 5)
    ElseIf m >= 12 And m < 24 Then
        Call findminangle(5 * (CDbl(h) + 0.2))
    ElseIf m >= 24 And m < 36 Then
        Call findminangle(5 * (CDbl(h) + 0.4))
    ElseIf m >= 36 And m < 48 Then
        Call findminangle(5 * (CDbl(h) + 0.6))
    ElseIf m >= 48 And m <= 59 Then
        Call findminangle(5 * (CDbl(h) + 0.8))
    End If
    xhor = xgen
    yhor = ygen
    If xhor >= Form1.ScaleWidth / 2 And yhor >= Form1.ScaleHeight / 2 Then
  
        Line (Form1.ScaleWidth / 2, Form1.ScaleHeight / 2)-(xhor - 200, yhor - 200), RGB(0, 0, 255)
    ElseIf xhor <= Form1.ScaleWidth / 2 And yhor >= Form1.ScaleHeight / 2 Then
        Line (Form1.ScaleWidth / 2, Form1.ScaleHeight / 2)-(xhor + 200, yhor - 200), RGB(0, 0, 255)
    ElseIf xhor <= Form1.ScaleWidth / 2 And yhor <= Form1.ScaleHeight / 2 Then
        Line (Form1.ScaleWidth / 2, Form1.ScaleHeight / 2)-(xhor + 200, yhor + 200), RGB(0, 0, 255)
    ElseIf xhor >= Form1.ScaleWidth / 2 And yhor <= Form1.ScaleHeight / 2 Then
        Line (Form1.ScaleWidth / 2, Form1.ScaleHeight / 2)-(xhor - 200, yhor + 200), RGB(0, 0, 255)
    End If
  
End Function
'draw the clock
Function drawdig()
    Dim i As Integer
    Circle (Form1.ScaleWidth / 2, Form1.ScaleHeight / 2), 1411, RGB(255, 34, 34)
    For i = 5 To 60
        Call findminangle(CDbl(i))
        Form1.CurrentX = xgen - TextWidth(i / 5) / 2
        Form1.CurrentY = ygen - TextWidth(i / 5) / 2
        Form1.Print i / 5
        i = i + 4
    Next
End Function
'find the co-ordinate
Function findminangle(p As Double)
    Dim temp As Double
  
    temp = 60 - (p - 15)
    temp = temp * 60 * 0.1
    temp = (22 * temp) / (7 * 180)
    
    xgen = (Form1.ScaleWidth / 2) + (1000 * Cos(temp))
    ygen = (Form1.ScaleHeight / 2) - (1000 * Sin(temp))
    
End Function
Private Sub Timer1_Timer()
Form1.Cls
Call drawdig
Form1.Caption = Time()
h = Hour(Time())
m = Minute(Time())
s = Second(Time())
Call mint
Call secnd
Call hr
End Sub


free counters

Halaman

Diberdayakan oleh Blogger.