2009年2月25日 星期三

數字跳動版 Lucky Seven

image

'數字跳動版 Lucky Seven
Public Class Form1
    Dim n1, k1
    Dim n2, k2
    Dim n3, k3
    Dim money, s7
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Randomize()
        money = 1000
        Timer1.Interval = 150
        Timer1.Enabled = False

        With Label1
            .AutoSize = True
            .Text = 1
            .Font = New Font("impact", 55)
            .ForeColor = Color.Yellow
            .BackColor = Color.Blue
        End With
        With Label2
            .AutoSize = True
            .Text = 2
            .Font = New Font("impact", 55)
            .ForeColor = Color.Yellow
            .BackColor = Color.Blue
        End With
        With Label3
            .AutoSize = True
            .Text = 3
            .Font = New Font("impact", 55)
            .ForeColor = Color.Yellow
            .BackColor = Color.Blue
        End With
        With Label4
            .AutoSize = True
            .Text = "$" & money
            .Font = New Font("impact", 20)
            .ForeColor = Color.Red
        End With
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        money = money - 50
        Label4.Text = "$" & money

        n1 = Int(Rnd() * 10)
        k1 = 0
        Timer1.Enabled = True

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

        n3 = Int(Rnd() * 10)
        k3 = 0
        Timer3.Enabled = True

        If n1 = 7 Then s7 = s7 + 1
        If n2 = 7 Then s7 = s7 + 1
        If n3 = 7 Then s7 = s7 + 1
        If s7 = 3 Then money = money + 6000
        If s7 = 2 Then money = money + 600
        If s7 = 1 Then money = money + 60
    End Sub

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

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

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

沒有留言:

張貼留言