运行效果:
VB编程:Timer控件中使用计数变量-24_彭世瑜_新浪博客_c++

 
程序代码:
Private myint As Integer
Private Sub Form_Load()
    myint = 0
End Sub
 
Private Sub Timer1_Timer()
    myint = myint + 1
    If myint = 2 Then Me.BackColor = vbGreen
    If myint = 4 Then Me.BackColor = vbRed
    If myint = 6 Then Me.BackColor = vbBlue
    If myint = 10 Then myint = 0
End Sub