Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old March 8th, 2012, 03:54 PM
helpme42 helpme42 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2012
Posts: 15 helpme42 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 12 h 23 m 8 sec
Reputation Power: 0
Slot machine program

i'm creating a slot machine program. i already have my layout and the coding for the program to spin and everything. But, my problem is, i have a section where the user can increase of decrease their bet, and when the user loses/wins, i want their balance to be adjusted. for example, if the user bets $20, and loses, i would like the $20 to be subtracted from their balance. this is the coding i have so far

Code:


' Project name:         Slot Machine Project
' Project purpose:      Simulates a slot machine
' Created/revised by:   <your name> on <current date>

Option Explicit On
Option Strict On
Option Infer Off

Public Class MainForm

    Private Sub exitButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles exitButton.Click
        Me.Close()
    End Sub

    Private Sub clickHereButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles clickHereButton.Click
        Dim randGen As New Random
        Dim leftIndex As Integer
        Dim centerIndex As Integer
        Dim rightIndex As Integer
        Dim lost As Integer

        clickHereButton.Enabled = False
        For spins As Integer = 1 To 10
            leftIndex = randGen.Next(0, 6)
            leftPictureBox.Image =
                ImageList1.Images.Item(leftIndex)
            Me.Refresh()
            System.Threading.Thread.Sleep(50)

            centerIndex = randGen.Next(0, 6)
            centerPictureBox.Image =
                ImageList1.Images.Item(centerIndex)
            Me.Refresh()
            System.Threading.Thread.Sleep(50)

            rightIndex = randGen.Next(0, 6)
            rightPictureBox.Image =
                ImageList1.Images.Item(rightIndex)
            Me.Refresh()
            System.Threading.Thread.Sleep(50)

        Next spins

        If leftIndex = centerIndex AndAlso
            leftIndex = rightIndex Then
            MessageBox.Show("Congratulations!", "Winner",
                            MessageBoxButtons.OK,
                            MessageBoxIcon.Information)

        End If
        If leftIndex <> centerIndex AndAlso
            leftIndex <> rightIndex Then
            MessageBox.Show("Sorry, you lost! Please play again", "Loser",
                            MessageBoxButtons.OK,
                            MessageBoxIcon.Information)
            lblBal.Text = lblBet - lost
        End If
        clickHereButton.Enabled = True




    End Sub

    
    Private Sub PictureBox2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox2.Click
        Static amount As Integer

        amount = amount + 5
        lblBet.Text = "$" & amount
    End Sub

    Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click
        Static amount As Integer

        amount = amount - 5
        lblBet.Text = "$" & amount
    End Sub

    Private Sub MainForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim balance As Integer

        balance = CInt(InputBox("Enter playing balance"))
        lblBal.Text = "$" & balance
    End Sub
End Class

Reply With Quote
  #2  
Old March 8th, 2012, 08:53 PM
Doug G Doug G is offline
Grumpier Old Moderator
Dev Shed God 19th Plane (14000 - 14499 posts)
 
Join Date: Jun 2003
Posts: 14,237 Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 4 Weeks 14 h 47 m 12 sec
Reputation Power: 4445
Does something not work with your code?
__________________
======
Doug G
======
It is a truism of American politics that no man who can win an election deserves to. --Trevanian, from the novel Shibumi

Reply With Quote
  #3  
Old March 8th, 2012, 11:45 PM
helpme42 helpme42 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2012
Posts: 15 helpme42 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 12 h 23 m 8 sec
Reputation Power: 0
everything worked fine in my code. but i was having problems coding my balance label. but i actually just finished working all the kinks out, so i have my program running the way it should be. it took me a while to figure it out, but i finally did.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming > Slot machine program

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap