You are viewing our Forum Archives. To view or take place in current topics click here.
[VB.NET] Need Help With My Program
Posted:

[VB.NET] Need Help With My ProgramPosted:

JtagFX
  • TTG Senior
Status: Offline
Joined: Jun 19, 201113Year Member
Posts: 1,055
Reputation Power: 39
Status: Offline
Joined: Jun 19, 201113Year Member
Posts: 1,055
Reputation Power: 39
What I'm Supposed to Make:
In this program you will create a slot machine. You will need three picture boxes to display at least 5 different pictures. You will also need one picture to be a wild card, so that the user wins if it comes up. Finally, you will need to have a text box to take in the users bet, a label to display the bank and a button to make the spinners change. The winning will be as follows:

3 of the same triple bet

1 wildcard keep bet

1 wildcard and 2 of the same double bet

None of the above - Lose the bet

HINT: To insert pictures you will use the command:

Picbox name.Image = Image.FromFile(Name of image.extension)

***THE IMAGES MUST BE STORED IN THE DEBUG (WHICH IS IN THE BIN FOLDER) FOLDER FOR THE PROJECT.


My code so far:

Public Class Form1
    Dim intscore, intbet, int1, int2, int3 As Integer

    Private Sub Form1_Load1(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        btnplcbet.Enabled = False 'disables place bet until you enter a bet
        btnspin.Enabled = False 'doesn't let you spin until you place a bet
        intscore = 200 'sets the default score to 200
        lblscore.Text = intscore
    End Sub

    Private Sub txtbet_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtbet.TextChanged
        btnplcbet.Enabled = True 'allows you to place a bet after you enter a bet
    End Sub

    Private Sub btnplcbet_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnplcbet.Click
        intbet = Val(txtbet.Text) 'sets the bet integer to what you choose as your bet
        btnspin.Enabled = True 'allows you to spin once you make a bet
    End Sub

    Private Sub btnspin_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnspin.Click
        int1 = 4 * Rnd() + 1 'sets a random number for each integer
        int2 = 4 * Rnd() + 1
        int3 = 4 * Rnd() + 1

        lblscore.Text = intscore

        If intscore < 1 Then 'makes the game end if your score drops less than 1
            btnplcbet.Enabled = False
            btnspin.Enabled = False

        End If

        'this gives you the amount of points you get based on whats shown on the slot machine
        'this part is where i know my problem is
        If int1 = 4 Or int2 = 4 Or int3 = 4 And int1 = int2 Then
            intscore = intscore + intbet * 2
        ElseIf int1 = 4 Or int2 = 4 Or int3 = 4 And int1 = int3 Then
            intscore = intscore + intbet * 2
        ElseIf int1 = 4 Or int2 = 4 Or int3 = 4 And int2 = int3 Then
            intscore = intscore + intbet * 2
        ElseIf int1 = 4 Or int2 = 4 Or int3 = 4 Then
            intscore = intscore + intbet
        ElseIf int1 = int2 And int2 = int3 Then
            intscore = intscore + intbet * 3
        Else : intscore = intscore - intbet
        End If


        'this generates the pictures for the slot machine
        If int1 = 1 Then
            picsym1.Image = Image.FromFile("cherry.bmp")
        ElseIf int1 = 2 Then
            picsym1.Image = Image.FromFile("grapes.bmp")
        ElseIf int1 = 3 Then
            picsym1.Image = Image.FromFile("orange.bmp")
        ElseIf int1 = 4 Then
            picsym1.Image = Image.FromFile("wild.bmp")
        ElseIf int1 = 5 Then
            picsym1.Image = Image.FromFile("watermelon.bmp")
        End If

        If int2 = 1 Then
            picsym2.Image = Image.FromFile("cherry.bmp")
        ElseIf int2 = 2 Then
            picsym2.Image = Image.FromFile("grapes.bmp")
        ElseIf int2 = 3 Then
            picsym2.Image = Image.FromFile("orange.bmp")
        ElseIf int2 = 4 Then
            picsym2.Image = Image.FromFile("wild.bmp")
        ElseIf int2 = 5 Then
            picsym1.Image = Image.FromFile("watermelon.bmp")
        End If

        If int3 = 1 Then
            picsym3.Image = Image.FromFile("cherry.bmp")
        ElseIf int3 = 2 Then
            picsym3.Image = Image.FromFile("grapes.bmp")
        ElseIf int3 = 3 Then
            picsym3.Image = Image.FromFile("orange.bmp")
        ElseIf int3 = 4 Then
            picsym3.Image = Image.FromFile("wild.bmp")
        ElseIf int3 = 5 Then
            picsym1.Image = Image.FromFile("watermelon.bmp")
        End If

    End Sub
End Class


My Design:
[ Register or Signin to view external links. ]
#2. Posted:
Rhymes
  • TTG Addict
Status: Offline
Joined: Dec 30, 201112Year Member
Posts: 2,311
Reputation Power: 120
Status: Offline
Joined: Dec 30, 201112Year Member
Posts: 2,311
Reputation Power: 120
What exactly is the problem with your program?
#3. Posted:
JtagFX
  • TTG Senior
Status: Offline
Joined: Jun 19, 201113Year Member
Posts: 1,055
Reputation Power: 39
Status: Offline
Joined: Jun 19, 201113Year Member
Posts: 1,055
Reputation Power: 39
it doesnt calculate the problems correctly
#4. Posted:
Imp
  • Blind Luck
Status: Offline
Joined: Jan 01, 201113Year Member
Posts: 1,957
Reputation Power: 401
Status: Offline
Joined: Jan 01, 201113Year Member
Posts: 1,957
Reputation Power: 401
JtagFX wrote it doesnt calculate the problems correctly


Just reading the code, not copied into VB, your If statement doesn't follow the instructions.

3 of the same triples bet.

If int1 = int2 And int2 = int3 then

1 wildcard keep bet.

If int1 = 4 Or int2 = 4 Or int3 = 4 then

1 wildcard and 2 the same double bet.

If (int1 = 4 Or int2 = 4 Or int3 = 4) And (int1 = int2 Or int1 = int3 Or int2 = int3) then

I wont do the rest for you, but thats how the basics of the If statement should go.
Jump to:
You are viewing our Forum Archives. To view or take place in current topics click here.