All pastes #2045448 Raw Edit

Stuff

public text v1 · immutable
#2045448 ·published 2011-04-12 13:17 UTC
rendered paste body
Public Class Form1

    Private tokens As Integer



    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        'Start game with 100 tokens

        tokens = 100
        lblTokens.Text = tokens

    End Sub



    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPull.Click




        Randomize()

        Dim num1 As Integer
        Dim num2 As Integer
        Dim num3 As Integer

        num1 = Int(3 * Rnd() + 1)
        num2 = Int(3 * Rnd() + 1)
        num3 = Int(3 * Rnd() + 1)



        lblSlotnum1.Text = num1

        lblSlotnum2.Text = num2

        lblSlotnum3.Text = num3



        ' Subracts the 1 token for the pull

        tokens = tokens - 1



        ' Calls checkWin to see if you won, gives 4,8,12 tokens. Or gives none

        tokens = tokens + checkWin(num1, num2, num3)

        lblTokens.Text = tokens
    End Sub



    Private Function checkWin(ByVal num1 As Integer, ByVal num2 As Integer, ByVal num3 As Integer) As Integer

        If num1 = 1 And num2 = 1 And num3 = 1 Then
            MessageBox.Show("You get 4 tokens!")
            Return 4

        End If

        If num1 = 2 And num2 = 2 And num3 = 2 Then
            MessageBox.Show("You get 8 tokens!")
            Return 8

        End If

        If num1 = 3 And num2 = 3 And num3 = 3 Then
            MessageBox.Show("You get 12 tokens!")
            Return 12

        End If

        Return 0

    End Function
End Class