设计一个VB程序,在标签中显示当前时间,要求标签背景色从白色逐渐变化到黑色并重复循环。
展开全部
Dim r, g, b As Long
Dim t As Boolean
Private Sub Form_Load()
r = 255
g = 255
b = 255
t = False
Timer1.Interval=50
End Sub
Private Sub Timer1_Timer()
Label1.Caption = Format(Time, "long time")
Label1.BackColor = RGB(r, g, b)
If t Then
r = r + 1
g = g + 1
b = b + 1
Else
r = r - 1
g = g - 1
b = b - 1
End If
If r = 255 Then t = False
If r = 0 Then t = True
End Sub
'在主窗体中添加两个控件Label,Timer
'然后添加如上代码
Dim t As Boolean
Private Sub Form_Load()
r = 255
g = 255
b = 255
t = False
Timer1.Interval=50
End Sub
Private Sub Timer1_Timer()
Label1.Caption = Format(Time, "long time")
Label1.BackColor = RGB(r, g, b)
If t Then
r = r + 1
g = g + 1
b = b + 1
Else
r = r - 1
g = g - 1
b = b - 1
End If
If r = 255 Then t = False
If r = 0 Then t = True
End Sub
'在主窗体中添加两个控件Label,Timer
'然后添加如上代码
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询