How can I create an analog Clock ?
it needs some Math
[php]
Dim x, y, w, m
Private Sub Form_Paint()
' Geting the mid-point of the form to be (x,y)
y = Me.Height / 2
x = Me.Width / 2
w = 1700
'Drawing the Circle
DrawWidth = 4
Me.Circle (x, y), w
' Drawing the Hour Scorpion
DrawWidth = 4
Me.Line (x, y)-(x + (900 * Sin(Hour(Now) * 3.1415 / 6)), _
y - (900 * Cos(Hour(Now) * 3.1415 / 6))), &HFFFF00
' Drawing the Minute Scorpion
DrawWidth = 3
Me.Line (x, y)-(x + (1200 * Sin(Minute(Now) * 3.1415 / 30)), _
y - (1200 * Cos(Minute(Now) * 3.1415 / 30))), vbYellow
' Drawing the Second Scorpion
DrawWidth = 1
Me.Line (x, y)-(x + (1500 * Sin(Second(Now) * 3.1415 / 30)), _
y - (1500 * Cos(Second(Now) * 3.1415 / 30))), vbRed
End Sub
Private Sub Timer1_Timer()
Me.Cls
'Drawing the Circle
DrawWidth = 4
Me.Circle (x, y), w
' Drawing the Hour Scorpion
DrawWidth = 4
Me.Line (x, y)-(x + (900 * Sin(Hour(Now) * 3.1415 / 6)), _
y - (900 * Cos(Hour(Now) * 3.1415 / 6))), &HFFFF00
' Drawing the Minute Scorpion
DrawWidth = 3
Me.Line (x, y)-(x + (1200 * Sin(Minute(Now) * 3.1415 / 30)), _
y - (1200 * Cos(Minute(Now) * 3.1415 / 30))), vbYellow
' Drawing the Second Scorpion
DrawWidth = 1
Me.Line (x, y)-(x + (1500 * Sin(Second(Now) * 3.1415 / 30)), y - (1500 * Cos(Second(Now) * 3.1415 / 30))), vbRed
End Sub
[/php]
من هذا المثال نلاحظ أن سطر الكود إذا كان طويلا فيمكن تقسيمه إلى عدة أسطر
و ذلك باستخدام ال(Under Score)
مثال على ذلك:
[php]
Me.Line (x, y)-(x + (1500 * Sin(Second(Now) * 3.1415 / 30)), _
y - (1500 * Cos(Second(Now) * 3.1415 / 30))), vbRed[/php]
[attachmentid=73627 name=frmClock.frm]