如題 :
利用 Timer、 Circle、line、VScroll ....等物件
寫一個 時鐘的 程式
且時間與真實世界之時間 一樣
秒針速度 因 VScroll 之數值 而改變!
詳細題型↓↓
http://cs.hccvs.hc.edu.tw/~tphsueh/exam942.exe → 24題
2006-05-16 06:24:17 · 1 個解答 · 發問者 佳君 5 in 電腦與網際網路 ➔ 程式設計
To W.J.S
一開始的時間是對的 可是一下子時間就亂了
你是否可重新看一次呢?
2006-05-16 16:46:31 · update #1
'表單放置1個Timer及1個VScrollBarConst Pi = 3.14159265358979Dim X&, Y&, R&, Hh%, Mm%, Ss%Private Sub Form_Load()Dim A&, B&, I%, J$, W%, H%X = ScaleWidth \ 2: Y = ScaleHeight \ 2R = X: If Y < X Then R = YR = R - 120AutoRedraw = True: DrawWidth = 1: ForeColor = 0J = 255For I = R To R + 90 Circle (X, Y), I, RGB(J, 0, J) J = J - 1NextJ = 1For I = 210 To 540 Step 30 W = TextWidth(J) \ 2 H = TextHeight(J) \ 2 CurrentX = X - Sin(I / 180 * Pi) * (R - W * 2) - W CurrentY = Y + Cos(I / 180 * Pi) * (R - H * 2) - H Print J: J = J + 1NextR = R - H * 3Picture = ImageVScroll1.Max = 1000: VScroll1.Min = 10: VScroll1 = 1000Hh = Hour(Now): Mm = Minute(Now): Ss = Second(Now)Timer1.Enabled = TrueEnd SubPrivate Sub Timer1_Timer()Dim S%, I%, J%ClsDrawWidth = 4S = ((Hh Mod 12) + Mm / 60) * 30 + 180I = X - Sin(S / 180 * Pi) * R * 0.6J = Y + Cos(S / 180 * Pi) * R * 0.6Line (X, Y)-(I, J)DrawWidth = 2S = Mm * 6 + 180I = X - Sin(S / 180 * Pi) * R * 0.8J = Y + Cos(S / 180 * Pi) * R * 0.8Line (X, Y)-(I, J)DrawWidth = 1S = Ss * 6 + 180I = X - Sin(S / 180 * Pi) * RJ = Y + Cos(S / 180 * Pi) * RLine (X, Y)-(I, J)Ss = Ss + 1If Ss > 59 Then Mm = Mm + 1: Ss = 0If Mm > 59 Then Hh = Hh + 1: Mm = 0If Hh > 12 Then Hh = 1 End SubPrivate Sub VScroll1_Change()Timer1.Interval = VScroll1End SubPrivate Sub VScroll1_Scroll()Timer1.Interval = VScroll1End Sub
2006-05-16 22:51:00 補充:
抱歉請在Timer事件中最後一行If Hh > 12 Then Hh = 1改成If Hh > 23 Then Hh = 0
2006-05-16 08:51:37 · answer #1 · answered by W.J.S. 7 · 0⤊ 0⤋