2009年2月19日 星期四

Lucky Seven 數字跳動版

image

Public Class Form1
    Dim acc As Integer

    '數字跳動版新增的程式碼
    Dim k1, n1
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        acc = 1000
        Randomize()
        Label1.Text = Int(Rnd() * 10)
        Label2.Text = Int(Rnd() * 10)
        Label3.Text = Int(Rnd() * 10)
        Label4.Text = "$" & acc
        With Label4
            .Font = New Font("arial", 26, FontStyle.Bold)
            .ForeColor = Color.Blue
        End With

        With Label1
            .ForeColor = Color.Yellow
            .BackColor = Color.Blue
            .Font = New Font("arial", 66, FontStyle.Bold)
        End With
        With Label2
            .ForeColor = Color.Yellow
            .BackColor = Color.Blue
            .Font = New Font("arial", 66, FontStyle.Bold)
        End With
        With Label3
            .ForeColor = Color.Yellow
            .BackColor = Color.Blue
            .Font = New Font("arial", 66, FontStyle.Bold)
        End With

    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        play()
    End Sub
    Sub play()  '副程式
        acc = acc - 50

        'Label1.Text = Int(Rnd() * 10)

        '數字跳動版新增的程式碼
        getN1()

        Label2.Text = Int(Rnd() * 10)
        Label3.Text = Int(Rnd() * 10)

        Dim n7 = 0
        If Label1.Text = 7 Then n7 = n7 + 1
        If Label2.Text = 7 Then n7 = n7 + 1
        If Label3.Text = 7 Then n7 = n7 + 1

        If n7 = 1 Then acc = acc + 60
        If n7 = 2 Then acc = acc + 600
        If n7 = 3 Then acc = acc + 6000
        Label4.Text = "$" & acc

        If acc < 1000 Then Label4.ForeColor = Color.Red
        If acc < 0 Then Label4.ForeColor = Color.Yellow
    End Sub

    '數字跳動版新增的程式碼
    Sub getN1()
        n1 = Int(Rnd() * 10)
        Timer1.Enabled = True
        k1 = 0
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim i
        For i = 1 To 10000
            play()
        Next
    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
End Class

沒有留言:

張貼留言