用VB编一个钟表,表针运动程序怎么编
2个回答
展开全部
Const π As Single = 3.1415926
Dim t As Date, t0 As Date, t1 As Date, t2 As Date, k As Integer
Private Sub Command1_Click()
Picture1.Cls
For i = 0 To 59
Picture1.Line ((90 * Cos(π / 2 + 6 * i * π / 180)), 90 * Sin(π / 2 + 6 * i * π / 180))-(95 * Cos(π / 2 + 6 * i * π / 180), 95 * Sin(π / 2 + 6 * i * π / 180)), vbBlue
Next i
Timer1.Interval = 1000
k = 0
Picture1.Line (0, 0)-(80 * Cos(π / 2 + 6 * k * π / 180), 80 * Sin(π / 2 + 6 * k * π / 180)), vbRed
t0 = Time
End Sub
Private Sub Command2_Click()
Timer1.Interval = 0
End Sub
Private Sub Form_Load()
Picture1.AutoRedraw = True
Picture1.Scale (-100, 100)-(100, -100)
Picture1.PSet (0, 0)
For i = 0 To 59
Picture1.Line ((90 * Cos(π / 2 + 6 * i * π / 180)), 90 * Sin(π / 2 + 6 * i * π / 180))-(95 * Cos(π / 2 + 6 * i * π / 180), 95 * Sin(π / 2 + 6 * i * π / 180)), vbBlue
Next i
Picture1.Line (0, 0)-(80 * Cos(π / 2 + 6 * k * π / 180), 80 * Sin(π / 2 + 6 * k * π / 180)), vbRed
End Sub
Private Sub Timer1_Timer()
Picture1.Cls
Label1.Caption = CDate(Time - t0)
For i = 0 To 59
Picture1.Line ((90 * Cos(π / 2 + 6 * i * π / 180)), 90 * Sin(π / 2 + 6 * i * π / 180))-(95 * Cos(π / 2 + 6 * i * π / 180), 95 * Sin(π / 2 + 6 * i * π / 180)), vbBlue
Next i
k = k + 1
Picture1.Line (0, 0)-(80 * Cos(π / 2 - 6 * k * π / 180), 80 * Sin(π / 2 - 6 * k * π / 180)), vbRed
If k >= 59 Then k = 0
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询