VB.net 2010 视频教程 VB.net 2010 视频教程 python基础视频教程
SQL Server 2008 视频教程 c#入门经典教程 Visual Basic从门到精通视频教程
当前位置:
首页 > 编程开发 > 批处理教程 >
  • vb.net教程之计时器

计时器(相关vb.net教程)
作用:完成一些自动的处理。
如动画、定时时钟、考试系统自动计时、自动模拟系统等。
常用属性:
Enabled:能用与否。
Interval:自动周期。
应用实例:制作一个红绿灯信号模拟系统。[实验报告26 ]
见红绿灯信号模拟系统。程序为:
        Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
 Static i, m As Integer
        i = i + 1 : TextBox1.Text = i
        Beep()
        If i >= 16 Then
            i = 0 : m = m + 1
        End If
        If (i >= 10 And i <= 16) Then
            L2.BackColor = Color.Yellow
            L2.Visible = Not L2.Visible
        Else
            L2.BackColor = Color.Blue
        End If
        If m Mod 2 = 0 Then
            L1.BackColor = Color.Green
            L3.BackColor = Color.Blue
        Else
            L1.BackColor = Color.Blue
            L3.BackColor = Color.Red
        End If
    End Sub
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        L1.BackColor = Color.Green
        L2.BackColor = Color.Blue
        L3.BackColor = Color.Blue
        Timer1.Interval = 1000
        Button1.Text = "退出"
        Me.BackColor = Color.Blue
        L1.Text = ""
        L2.Text = ""
        L3.Text = ""
    End Sub
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        End
    End Sub

相关教程