'在窗体上建一个timer,3个图片框,复制以下代码即可:
Option Explicit
Private Sub Form_Load()
Timer1.Interval = 3000'设置间隔时间为3秒
End Sub
Private Sub Timer1_Timer()
Static i As Integer
i = i + 1
If i = 1 Then Picture1.BackColor = vbRed: Picture2.BackColor = Me.BackColor: Picture3.BackColor = Me.BackColor
If i = 2 Then Picture1.BackColor = Me.BackColor: Picture2.BackColor = vbGreen: Picture3.BackColor = Me.BackColor
If i = 3 Then Picture1.BackColor = Me.BackColor: Picture2.BackColor = Me.BackColor: Picture3.BackColor = vbYellow
If i >= 3 Then i = 0
End Sub
假如你使用Picture控件来存放颜色图片
PictureRED PictureGreen PictureBLUE
dim a as Long
Private Sub Timer1_Timer()
If a Mod 3 = 1 Then
PictureBLUE.Visible = True
PictureRED.Visible = False
PictureGREEN.Visible = False
ElseIf a Mod 3 = 2 Then
PictureRED.Visible = True
PictureGREEN.Visible = False
PictureBLUE.Visible = False
Else
PictureGREEN.Visible = True
PictureBLUE.Visible = False
PictureRED.Visible = False
End If
a = a + 1
If a > 100000 Then
a = 0
End If
End Sub