2009年2月23日 星期一

數字跳動3字自動停止版

image

'簡易版數字變化效果
'到一定數字會停止

'擴為3個字

Public Class Form1
    Dim i1, i2, i3
    Dim n1, n2, n3
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Randomize()
        Timer1.Interval = 150
        Timer1.Enabled = False
        Timer2.Interval = 150
        Timer2.Enabled = False
        Timer3.Interval = 150
        Timer3.Enabled = False

        '格式設定
        With Label1
            .BackColor = Color.Blue
            .ForeColor = Color.Yellow
            .Font = New Font("Arial Black", 50)
            .AutoSize = True
        End With
        With Label2
            .BackColor = Color.Blue
            .ForeColor = Color.Yellow
            .Font = New Font("Arial Black", 50)
            .AutoSize = True
        End With
        With Label3
            .BackColor = Color.Blue
            .ForeColor = Color.Yellow
            .Font = New Font("Arial Black", 50)
            .AutoSize = True
        End With
    End Sub

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Label1.Text = i1
        If i1 = n1 Then Timer1.Enabled = False
        i1 = i1 + 1
    End Sub

    Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
        Label2.Text = i2
        If i2 = n2 Then Timer2.Enabled = False
        i2 = i2 + 1
    End Sub

    Private Sub Timer3_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer3.Tick
        Label3.Text = i3
        If i3 = n3 Then Timer3.Enabled = False
        i3 = i3 + 1
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        i1 = 0
        Timer1.Enabled = True
        n1 = Int(Rnd() * 10)

        i2 = 0
        Timer2.Enabled = True
        n2 = Int(Rnd() * 10)

        i3 = 0
        Timer3.Enabled = True
        n3 = Int(Rnd() * 10)
    End Sub

End Class

沒有留言:

張貼留言