Pages

Jumat, 02 Januari 2009

cara membuat jam analog

'***************************************************************************
'
' Visual Basic Source Code
' Situs mengenai seputar pemograman menggunakan visual basic.
' http://www.vbbego.cjb.net
'
' Kirim pertanyaan anda ke:
'
' vbhelp_us@ yahoo.com
' mail42me@ telkom.net
' VanJava@ telkom.net
'
' Author: CyberBoy - BEGO admin
' Update terakhir, Maret - 2004
' » http://groups.yahoo.com/group/vb_bego
'
' NB: Anda Boleh mengedit source code ini, tanpa menghilangkan
' nama pembuat asli
'***************************************************************************

Option Explicit
Dim timAng, timX, timY, timRi As Integer
Sub AlineTimeLoad(timFrm As Variant)
Dim timCo, timI, timJ As Integer
timFrm.timShape1.Width = timFrm.timShape1.Height
timX = (timFrm.timShape1.Width / 2 + timFrm.timShape1.Left) * 2 '.Width
timY = (timFrm.timShape1.Height / 2 + timFrm.timShape1.Top) * 2 'Height * 0.75
timFrm.timShape1.Height = timFrm.timShape1.Width
timFrm.timImage1(0).ZOrder 0
timFrm.timLine1.ZOrder 0
timFrm.timImage2(0).ZOrder 1
For timI = 1 To 11
Load timFrm.timImage1(timI)
timFrm.timImage1(timI).Visible = True
Next
For timI = 1 To 59
Load timFrm.timImage2(timI)
timFrm.timImage2(timI).Visible = True
Next
With timFrm.timLine1
.X1 = timX / 2
.Y1 = timY / 2
End With
With timFrm.timLine2
.X1 = timX / 2
.Y1 = timY / 2
End With
With timFrm.timLine3
.X1 = timX / 2
.Y1 = timY / 2
End With
timRi = timFrm.timShape1.Width / 2
timFrm.timShape1.Left = (timX - timFrm.timShape1.Width) / 2
timFrm.timShape1.Top = (timY - timFrm.timShape1.Height) / 2

For timI = 0 To 11
timAng = timI * 360 / 12 - 90
With timFrm.timImage1(timI)
.Left = (timRi + timFrm.timShape1.Width / 20) * Cos(3.141 / 180 * timAng) + timX / 2 - .Width / 2
.Top = (timRi + timFrm.timShape1.Width / 20) * Sin(3.141 / 180 * timAng) + timY / 2 - .Height / 2
.Visible = timFrm.timImage1(0).Visible
End With
Next
For timI = 0 To 59
timAng = timI * 6 - 90
With timFrm.timImage2(timI)
.Left = (timRi + timFrm.timShape1.Width / 20) * Cos(3.141 / 180 * timAng) + timX / 2 - .Width / 2
.Top = (timRi + timFrm.timShape1.Width / 20) * Sin(3.141 / 180 * timAng) + timY / 2 - .Height / 2
.Visible = timFrm.timImage2(0).Visible
End With
Next
End Sub
Sub ShowTime(timFrm As Variant, tempTime As Date)
On Error GoTo ErrH
timAng = Minute(tempTime) * 6 - 90 + Second(tempTime) / 10
timAng = timAng Mod 360
ShowTime1 timFrm.timLine2, CDbl(timAng)
timAng = Second(tempTime) * 6 - 90
timAng = timAng Mod 360
ShowTime1 timFrm.timLine1, CDbl(timAng)
timRi = timRi * 0.65
timAng = (Hour(tempTime) Mod 12) * (360 / 12) - 90 + (Minute(tempTime)) / 2
timAng = timAng Mod 360
ShowTime1 timFrm.timLine3, CDbl(timAng)
ErrH:
timRi = timRi / 0.65
End Sub

Sub ShowTime1(timTempLine As Variant, timTempAng As Double)
With timTempLine
.X2 = timRi * Cos(timTempAng * 3.141 / 180) + timX / 2
.Y2 = timRi * Sin(timTempAng * 3.141 / 180) + timY / 2
End With
End Sub

Private Sub Form_Load()
AlineTimeLoad Me
End Sub
Private Sub Timer1_Timer()
ShowTime Me, Time
End Sub

Tidak ada komentar: