几行代码就实现一个图形时钟程序
源码:
时钟.rar
(7.97 KB)
效果:
程序代码:
Private Const PI = 3.14159265 Private Sub Form_Load() Me.Scale (-2000, 2000)-(2000, -2000) End Sub Private Sub Timer1_Timer() Me.Cls For i = 0 To 360 Step 30 Me.DrawWidth = 5 Me.PSet (Sin(PI / 180 * i) * 500, Cos(PI / 180 * i) * 600), vbGreen Next Me.DrawWidth = 1 Me.Line (-2000, 0)-(2000, 0), vbBlack Me.Line (0, 2000)-(0, -2000), vbBlack Me.DrawWidth = 2 '秒 Me.Line (0, 0)-(Sin(PI / 180 * Second(Now) * 6) * 500, Cos(PI / 180 * Second(Now) * 6) * 500), vbRed '分 Me.Line (0, 0)-(Sin(PI / 180 * Minute(Now) * 6) * 400, Cos(PI / 180 * Minute(Now) * 6) * 400), vbYellow '时 Me.Line (0, 0)-(Sin(PI / 180 * Hour(Now) * 30) * 300, Cos(PI / 180 * Hour(Now) * 30) * 300), vbBlack End Sub