vb时间标签一秒一更新标签背景颜色每一点五秒红蓝替
发布网友
发布时间:2022-05-21 17:43
我来回答
共3个回答
热心网友
时间:2023-11-04 09:33
设置两个TIMER控件,一个设置1秒,一个设置1.5秒 , 标签控件:Label1
代码如下:
Private Sub Form_Load()
Label1.Caption = Time()
Label1.BackColor = vbRed
Timer1.Interval = 1000
Timer2.Interval = 1500
End Sub
Private Sub Timer1_Timer()
Label1.Caption = Time()
End Sub
Private Sub Timer2_Timer()
If Label1.BackColor = vbRed Then
Label1.BackColor = vbBlue
Else
Label1.BackColor = vbRed
End If
End Sub
热心网友
时间:2023-11-04 09:34
用Timer控件,在触发中设置就可以。注意1000才是1秒
热心网友
时间:2023-11-04 09:34
Dim num As Integer
Private Sub Form_Load()
Label1.Caption = Time
Label1.BackColor = vbRed
Timer1.Interval = 500
Timer1.Enabled = True
End Sub
Private Sub Timer1_Timer()
num = num + 1
If num = 2 Then
Label1.Caption = Time
ElseIf num = 3 Then
If Label1.BackColor = vbRed Then
Label1.BackColor = vbBlue
Else
Label1.BackColor = vbRed
End If
num = 0
End If
End Sub