第二部,添加一个计时器timer,一个文字标签label
第三部,输入代码,代码如下
Private Sub Form_Load()
picClock.Move (Me.ScaleWidth - 8 * 210) / 2, (Me.ScaleHeight - 315) / 2, 8 * 210, 315
Dim i&
For i = 0 To 7
picClock.PaintPicture picNumber.Picture, i * 210, 0, 210, 315, IIf((i = 2) Or (i = 5), 12, 10) * 210, 0, 210, 315
Next i
End Sub
Private Sub Timer1_Timer()
Dim cNow$, i&
cNow = Format(Now, "hh:mm:ss")
For i = 0 To 7
If Mid(cNow, i + 1, 1) <>":" Then
picClock.PaintPicture picNumber.Picture, i * 210, 0, 210, 315, Val(Mid(cNow, i + 1, 1)) * 210, 0, 210, 315
End If
Next i
End Sub
望采纳
上面的代码错了,下面是正确代码
Private Sub Form_Load()
Timer1.Enabled = True
Timer1.Interval = 300
End Sub
Private Sub Timer1_Timer()
Label1 = Now
End Sub
label字乎春体什么的枯乎自己改吧,主要功能实现了Private Sub Form_Load()
Timer1.Enabled = True
Timer1.Interval = 1000
Timer2.Enabled = False
Timer2.Interval = 500
End Sub
Private Sub Timer1_Timer()
Label1.Caption = Time
End Sub
Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then
If Not IsDate(Text1.Text) Then
MsgBox "时间格没顷悉式错误,正确应为HH:MM:SS"
Else
Text1.Locked = True
Timer2.Enabled = True
End If
End If
End Sub
Private Sub Timer2_Timer()
Dim lTime As Integer
Static LblColor As Boolean
lTime = DateDiff("s", Time, Text1.Text)
If lTime <= 0 Then
If LblColor = True Then
Label1.BackColor = vbRed
LblColor = False
Else
Label1.BackColor = vbWhite
LblColor = True
End If
End If
End Sub
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)