private
sub
timer1_timer()
label1.caption
=
time
end
sub就行了。谢谢采纳
下面是一个时钟程序代码,你可以参考一下。Const PI = 3.14159265
Dim H, W, R As Integer '窗体高、宽、圆半径
Private Sub BiaoKe()
Dim I As Integer
'外盘
Circle (W \ 2, H \胡衡 2), R, vbBlue
'中心
Circle (W \ 2, H \ 2), 1, vbWhite
'盘面各点
For I = 0 To 59
If I Mod 5 = 0 Then
Circle (W \ 2 + R * Cos(I * PI / 30), H \ 2 + R * Sin(I * PI / 30)), 2, vbGreen
Else
Circle (W \ 2 + R * Cos(I * PI / 30), H \ 2 + R * Sin(I * PI / 30)), 1, vbWhite
End If
Next I
End Sub
Private Sub Form_Load()
Me.Show
Me.Cls
H = frmTime.ScaleHeight
W = frmTime.ScaleWidth
R = W \ 4
lbTime.Left = (frmTime.ScaleWidth - lbTime.Width) \ 2
lbTime.Top = frmTime.ScaleHeight - R \ 4
End Sub
Private Sub Form_Resize()
Call Form_Load
End Sub
Private Sub Timer1_Timer()
Dim T1, T2, T3 As Integer
Dim I, J, K As Integer
Me.Cls
T1 = Hour(Time): T2 = Minute(Time): T3 = Second(Time)
I = T1 - 15
J = T2 - 15
K = T3 - 15
'钟表裤岩做外壳
Call BiaoKe
'画时针
Line (W \ 2, H \ 2)-(W \ 2 + 0.5 * (R * Cos((I + J / 60) * PI / 6)), H \ 2 + 0.5 * (R * Sin((I + J / 60) * PI / 6))), vbGreen
'画分针
Line (W \ 2, H \ 2)-(W \ 2 + 0.7 * (R * Cos((J + K / 60) * PI / 30)), H \ 2 + 0.7 * (R * Sin((J + K / 60) * PI /枣伍 30))), vbYellow
'画秒针
Line (W \ 2, H \ 2)-(W \ 2 + 0.9 * (R * Cos(K * PI / 30)), H \ 2 + 0.9 * (R * Sin(K * PI / 30))), vbRed
K = K + 1
If K >360 Then K = K Mod 360
lbTime.Caption = Time
End Sub
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)