2009年4月14日 星期二

計時器綜合應用

image

Public Class Form1
    Dim s = 0
    Dim m = 0
    Dim str1 = "綜二○一班明天會更好綜二○一班明天會更好"
    Dim i = 0
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Timer1.Enabled = True
        Timer1.Interval = 1000
    End Sub

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Dim j = i Mod 5 + 1
        s = s + 1
        If s >= 60 Then
            m = m + 1
            s = s - 60
        End If
        Label1.Text = Now
        Label2.Text = m & ":" & s
        With Label3
            .Text = Mid(str1, j, 10)
            .Font = New Font("標楷體", 20, FontStyle.Bold)
            .BackColor = Color.Blue
            .ForeColor = Color.Yellow
        End With
        i = i + 1
    End Sub
End Class

沒有留言:

張貼留言