需要用電腦的現在時間做出一個時鐘
每動一秒 秒針需要跟個跑
利用函數 Sin及cos當秒針分針時針的角度
line畫線當秒針分針時針
circle畫圓
拜託拜託~送20點喔!!
2006-04-13 18:24:25 · 1 個解答 · 發問者 默默 1 in 電腦與網際網路 ➔ 程式設計
'表單上置1個TimerConst Pi = 3.14159265358979 '圓周率Dim X&, Y&, R&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 - 30AutoRedraw = True: DrawWidth = 2: FillStyle = 0ForeColor = 100: FillColor = vbWhiteCircle (X, Y), R: Circle (X, Y), R / 30J = 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 * 3Set Picture = ImageAutoRedraw = FalseTimer1.Enabled = TrueTimer1.Interval = 1000End SubPrivate Sub Timer1_Timer()Dim S%, I%, J%, Z$ClsZ = Format(Date, "e年m月d日")CurrentX = X - TextWidth(Z) / 2CurrentY = Y * 1.5Print ZDrawWidth = 3S = ((Hour(Now) Mod 12) + Minute(Now) / 60) * 30 + 180I = X - Sin(S / 180 * Pi) * R * 0.6J = Y + Cos(S / 180 * Pi) * R * 0.6Line (X, Y)-(I, J), vbBlueDrawWidth = 2S = Minute(Now) * 6 + 180I = X - Sin(S / 180 * Pi) * R * 0.8J = Y + Cos(S / 180 * Pi) * R * 0.8Line (X, Y)-(I, J), vbGreenDrawWidth = 1S = Second(Now) * 6 + 180I = X - Sin(S / 180 * Pi) * RJ = Y + Cos(S / 180 * Pi) * RLine (X, Y)-(I, J), 255End Sub
2006-04-14 10:37:41 · answer #1 · answered by W.J.S. 7 · 0⤊ 0⤋