2009年2月23日 星期一

簡易版數字變化自動停止版

 

image

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

Public Class Form1
    Dim i
    Dim n1
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Randomize()
        Timer1.Interval = 50
        Timer1.Enabled = False
        i = 0

        '格式設定
        With Label1
            .BackColor = Color.Blue
            .ForeColor = Color.Yellow
            .Font = New Font("Arial Black", 60)
            .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 = i
        If i = n1 Then Timer1.Enabled = False
        i = i + 1
    End Sub

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

沒有留言:

張貼留言