This is a slot machine game, 2 forms. One is the actual game (frmMachine) and the other is in the background and randomizes the images shown on frmMachine. I need to make frmMachine wait for frmRandom, i tried it with the Sleep API and a Do/Until Loop and neither worked, could you please help me, I have my code below.
frmMachine -
'Slot Machine, (c) 2006 Peter Browne, GPL Licensed
-
'
-
'Peter Browne
-
'Sheridan Corporate Centre
-
'2155 Leanne Blvd., Ste. 200B
-
'Mississauga ON L5K 2K8
-
'(905) 616-6099
-
'peterrbrowne@hotmail.com
-
'
-
'
-
'PPPPPPPPPPPPPPPPPPPPPPPPP PPPPPPPPPPPPPPPPPPPPPPPPP BBBBBBBBBBBBBBBBBBBB
-
' PPPPPPPPPPPPPPPPPPPPPPPPPPP PPPPPPPPPPPPPPPPPPPPPPPPPP B BB
-
' PPPPPPPPP PP PPPPPPPPP PP B BB
-
' PPPPPPPPP PP PPPPPPPPP PP B BB
-
' PPPPPPPPP P PPPPPPPPP P B BB
-
' PPPPPPPPPPPPPPPPPPPPPPP PPPPPPPPPPPPPPPPPPPPPPPP B BB
-
' PPPPPPPPP PPPPPPPPPRRR B BB
-
' PPPPPPPPP PPPPPPPPP RRR B BB
-
' PPPPPPPPP PPPPPPPPP RRR B BB
-
' PPPPPPPPP PPPPPPPPP RRR BBBBBBBBBBBBBBBBBBB
-
' PPPPPPPPP PPPPPPPPP RRR BBBBBBBBBBBBBBBBBBB
-
' PPPPPPPPP PPPPPPPPP RRR B BB
-
' PPPPPPPPP PPPPPPPPP RRR B BB
-
' PPPPPPPPP PPPPPPPPP RRR B BB
-
' PPPPPPPPP PPPPPPPPP RRR B BB
-
' PPPPPPPPP PPPPPPPPP RRR B BB
-
' PPPPPPPPP PPPPPPPPP RRR B BB
-
' PPPPPPPPP PPPPPPPPP RRR B BB
-
'PPPPPPPPPPP PPPPPPPPPPP RRR BBBBBBBBBBBBBBBBBBBB
-
'
-
' GNU GENERAL PUBLIC LICENSE
-
' Version 2, June 1991
-
'
-
' Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
-
' 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-
' Everyone is permitted to copy and distribute verbatim copies
-
' of this license document, but changing it is not allowed.
-
'
-
' Preamble
-
'
-
' The licenses for most software are designed to take away your
-
'freedom to share and change it. By contrast, the GNU General Public
-
'License is intended to guarantee your freedom to share and change free
-
'software--to make sure the software is free for all its users. This
-
'General Public License applies to most of the Free Software
-
'Foundation 's software and to any other program whose authors commit to
-
'using it. (Some other Free Software Foundation software is covered by
-
'the GNU Lesser General Public License instead.) You can apply it to
-
'your programs, too.
-
'
-
' When we speak of free software, we are referring to freedom, not
-
'price. Our General Public Licenses are designed to make sure that you
-
'have the freedom to distribute copies of free software (and charge for
-
'this service if you wish), that you receive source code or can get it
-
'if you want it, that you can change the software or use pieces of it
-
'in new free programs; and that you know you can do these things.
-
'
-
' To protect your rights, we need to make restrictions that forbid
-
'anyone to deny you these rights or to ask you to surrender the rights.
-
'These restrictions translate to certain responsibilities for you if you
-
'distribute copies of the software, or if you modify it.
-
'
-
' For example, if you distribute copies of such a program, whether
-
'gratis or for a fee, you must give the recipients all the rights that
-
'you have. You must make sure that they, too, receive or can get the
-
'source code. And you must show them these terms so they know their
-
'rights.
-
'
-
' We protect your rights with two steps: (1) copyright the software, and
-
'(2) offer you this license which gives you legal permission to copy,
-
'distribute and/or modify the software.
-
'
-
' Also, for each author's protection and ours, we want to make certain
-
'that everyone understands that there is no warranty for this free
-
'software. If the software is modified by someone else and passed on, we
-
'want its recipients to know that what they have is not the original, so
-
'that any problems introduced by others will not reflect on the original
-
'authors ' reputations.
-
'
-
' Finally, any free program is threatened constantly by software
-
'patents. We wish to avoid the danger that redistributors of a free
-
'program will individually obtain patent licenses, in effect making the
-
'program proprietary. To prevent this, we have made it clear that any
-
'patent must be licensed for everyone's free use or not licensed at all.
-
-
'Declares the variables
-
Dim Bet As String 'Amount Bet
-
Dim Amount As String 'Amount in Account
-
Dim RandomImage As Integer 'Random Image
-
Dim RandomCount As Integer 'Number of times random image is displayed
-
Public One As Integer 'First Image
-
Public Two As Integer 'Second Image
-
Public Three As Integer 'Third image
-
-
'Sleep
-
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
-
-
Private Sub Form_Load()
-
-
'Sets the starting amount
-
Amount = 250
-
-
'Shows the starting amount
-
lblAmount.Caption = "You have: $" + Str(Amount)
-
-
'Starts the music
-
OLE1.DoVerb ' (Play)
-
-
End Sub
-
-
Private Sub cmdPull_Click()
-
-
'Sets the bet as the input
-
Bet = txtBet.Text
-
-
'Checks to make sure that the bet is a number
-
If Not IsNumeric(Bet) Then
-
txtBet.Text = "" 'Clears the input
-
MsgBox ("Please enter a dollar amount.") 'Displays the message box
-
txtBet.SetFocus 'Sets the focus to be on the input
-
Exit Sub 'Ends the program
-
End If
-
-
'Checks to make sure the bet is positive
-
If Bet <= 0 Then
-
txtBet.Text = "" 'Clears the input
-
MsgBox ("You must enter $1 or more!") 'Displays the message box
-
txtBet.SetFocus 'Sets the focus to be on the input
-
Exit Sub 'Ends the program
-
End If
-
-
'Reduces the amount by the bet
-
Amount = Amount - Bet
-
lblAmount.Caption = "You Have: $" + Str(Amount)
-
-
'Checks if the user is trying to bankrupt themselves
-
If Amount <= 0 Then
-
Amount = Amount + Bet 'Raises the amount to the previous amount
-
MsgBox ("You can't bet more then you have!") 'Displays the Message Box
-
Exit Sub 'Ends the program
-
End If
-
-
'Calls frmRandom
-
frmRandom.Show
-
-
'Pauses for randomization
-
Do Until frmRandom.RandomCount = 30
-
Loop
-
-
'Winner
-
If One = Two And Two = Three Then 'Determines if user is a winner
-
-
If One = 1 Then 'Sequence for vehicle is One
-
Amount = Amount + 25 'Raises the amount by $25
-
MsgBox ("You win $25!") 'Displays Message Box
-
lblAmount.Caption = "You Have: $" + Str(Amount)
-
End If
-
-
If One = 2 Then 'Sequence for vehicle is Two
-
Amount = Amount + 30 'Raises the amount
-
MsgBox ("You Win $30!") 'Displays Message Box
-
lblAmount.Caption = "You Have: $" + Str(Amount)
-
End If
-
-
If One = 3 Then 'Sequence for vehicle is Three
-
Amount = Amount + 20 'Raises the amount
-
MsgBox ("You Win $20") 'Diplays Message Box
-
lblAmount.Caption = "You Have: $" + Str(Amount)
-
End If
-
-
If One = 4 Then 'Sequence for vehicle is Four
-
Amount = Amount - 35 'Lowers the Amount
-
-
If Amount <= 0 Then 'Sequence for bankrupt users
-
Amount = 0
-
MsgBox ("You went bankrupt! I will now close!")
-
lblAmount.Caption = "You Have: $" + Str(Amount)
-
Unload frmMachine
-
Exit Sub
-
End If
-
-
MsgBox ("You Lost $35!")
-
lblAmount.Caption = "You Have: $" + Str(Amount)
-
End If
-
-
Else 'If user did not win
-
MsgBox ("You did not win!")
-
MsgBox ("Please try again!")
-
-
End If
-
End Sub
-
-
Private Sub cmdDone_Click()
-
-
'Closes the program
-
Unload frmMachine
-
-
End Sub
-
1 5647
frmRandom -
'Slot Machine, (c) 2006 Peter Browne, GPL Licensed
-
'
-
'Peter Browne
-
'Sheridan Corporate Centre
-
'2155 Leanne Blvd., Ste. 200B
-
'Mississauga ON L5K 2K8
-
'(905) 616-6099
-
'peterrbrowne@hotmail.com
-
'
-
'
-
'PPPPPPPPPPPPPPPPPPPPPPPPP PPPPPPPPPPPPPPPPPPPPPPPPP BBBBBBBBBBBBBBBBBBBB
-
' PPPPPPPPPPPPPPPPPPPPPPPPPPP PPPPPPPPPPPPPPPPPPPPPPPPPP B BB
-
' PPPPPPPPP PP PPPPPPPPP PP B BB
-
' PPPPPPPPP PP PPPPPPPPP PP B BB
-
' PPPPPPPPP P PPPPPPPPP P B BB
-
' PPPPPPPPPPPPPPPPPPPPPPP PPPPPPPPPPPPPPPPPPPPPPPP B BB
-
' PPPPPPPPP PPPPPPPPPRRR B BB
-
' PPPPPPPPP PPPPPPPPP RRR B BB
-
' PPPPPPPPP PPPPPPPPP RRR B BB
-
' PPPPPPPPP PPPPPPPPP RRR BBBBBBBBBBBBBBBBBBB
-
' PPPPPPPPP PPPPPPPPP RRR BBBBBBBBBBBBBBBBBBB
-
' PPPPPPPPP PPPPPPPPP RRR B BB
-
' PPPPPPPPP PPPPPPPPP RRR B BB
-
' PPPPPPPPP PPPPPPPPP RRR B BB
-
' PPPPPPPPP PPPPPPPPP RRR B BB
-
' PPPPPPPPP PPPPPPPPP RRR B BB
-
' PPPPPPPPP PPPPPPPPP RRR B BB
-
' PPPPPPPPP PPPPPPPPP RRR B BB
-
'PPPPPPPPPPP PPPPPPPPPPP RRR BBBBBBBBBBBBBBBBBBBB
-
'
-
' GNU GENERAL PUBLIC LICENSE
-
' Version 2, June 1991
-
'
-
' Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
-
' 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-
' Everyone is permitted to copy and distribute verbatim copies
-
' of this license document, but changing it is not allowed.
-
'
-
' Preamble
-
'
-
' The licenses for most software are designed to take away your
-
'freedom to share and change it. By contrast, the GNU General Public
-
'License is intended to guarantee your freedom to share and change free
-
'software--to make sure the software is free for all its users. This
-
'General Public License applies to most of the Free Software
-
'Foundation 's software and to any other program whose authors commit to
-
'using it. (Some other Free Software Foundation software is covered by
-
'the GNU Lesser General Public License instead.) You can apply it to
-
'your programs, too.
-
'
-
' When we speak of free software, we are referring to freedom, not
-
'price. Our General Public Licenses are designed to make sure that you
-
'have the freedom to distribute copies of free software (and charge for
-
'this service if you wish), that you receive source code or can get it
-
'if you want it, that you can change the software or use pieces of it
-
'in new free programs; and that you know you can do these things.
-
'
-
' To protect your rights, we need to make restrictions that forbid
-
'anyone to deny you these rights or to ask you to surrender the rights.
-
'These restrictions translate to certain responsibilities for you if you
-
'distribute copies of the software, or if you modify it.
-
'
-
' For example, if you distribute copies of such a program, whether
-
'gratis or for a fee, you must give the recipients all the rights that
-
'you have. You must make sure that they, too, receive or can get the
-
'source code. And you must show them these terms so they know their
-
'rights.
-
'
-
' We protect your rights with two steps: (1) copyright the software, and
-
'(2) offer you this license which gives you legal permission to copy,
-
'distribute and/or modify the software.
-
'
-
' Also, for each author's protection and ours, we want to make certain
-
'that everyone understands that there is no warranty for this free
-
'software. If the software is modified by someone else and passed on, we
-
'want its recipients to know that what they have is not the original, so
-
'that any problems introduced by others will not reflect on the original
-
'authors ' reputations.
-
'
-
' Finally, any free program is threatened constantly by software
-
'patents. We wish to avoid the danger that redistributors of a free
-
'program will individually obtain patent licenses, in effect making the
-
'program proprietary. To prevent this, we have made it clear that any
-
'patent must be licensed for everyone's free use or not licensed at all.
-
'
-
Dim RandomImage As Integer 'Random Image
-
Public RandomCount As Integer 'Number of times random image is displayed
-
Public One As Integer 'First Image
-
Public Two As Integer 'Second Image
-
Public Three As Integer 'Third image
-
-
Private Sub tmrOne_Timer()
-
-
'Code to randomize imgOne and display the images
-
'RandomCount = 0 'Resets the RandomCount
-
'Do Until RandomCount = 10 'Start the Loop
-
RandomCount = RandomCount + 1 'Add one to RandomCount
-
RandomImage = Int(4 * Rnd + 1) 'Selects a random image
-
If RandomImage = 1 Then 'If the random image is 1 then...
-
One = 1
-
frmMachine.imgOne.Picture = LoadPicture("G:\crossblade.bmp")
-
End If
-
If RandomImage = 2 Then 'If image 2 is selected
-
One = 2
-
frmMachine.imgOne.Picture = LoadPicture("G:\crosstown.bmp")
-
End If
-
If RandomImage = 3 Then 'If the random image is 1 then...
-
One = 3
-
frmMachine.imgOne.Picture = LoadPicture("G:\hello yellow.bmp")
-
End If
-
If RandomImage = 4 Then 'If the random image is 1 then...
-
One = 4
-
frmMachine.imgOne.Picture = LoadPicture("G:\h1.bmp")
-
End If
-
'Loop
-
-
'Code to randomize imgTwo and display the images
-
'RandomCount = 0 'Resets the RandomCount
-
'Do Until RandomCount = 20 'Start the Loop
-
RandomCount = RandomCount + 1 'Add one to RandomCount
-
RandomImage = Int(4 * Rnd + 1) 'Selects a random image
-
If RandomImage = 1 Then 'If the random image is 1 then...
-
Two = 1
-
frmMachine.imgTwo.Picture = LoadPicture("G:\crossblade.bmp")
-
End If
-
If RandomImage = 2 Then 'If image 2 is selected
-
Two = 2
-
frmMachine.imgTwo.Picture = LoadPicture("G:\crosstown.bmp")
-
End If
-
If RandomImage = 3 Then 'If the random image is 1 then...
-
Two = 3
-
frmMachine.imgOne.Picture = LoadPicture("G:\hello yellow.bmp")
-
End If
-
If RandomImage = 4 Then 'If the random image is 1 then...
-
Two = 4
-
frmMachine.imgOne.Picture = LoadPicture("G:\h1.bmp")
-
End If
-
'Loop
-
-
'Code to randomize imgThree and display the images
-
'RandomCount = 0 'Resets the RandomCount
-
'Do Until RandomCount = 30 'Start the Loop
-
RandomCount = RandomCount + 1 'Add one to RandomCount
-
RandomImage = Int(4 * Rnd + 1) 'Selects a random image
-
If RandomImage = 1 Then 'If the random image is 1 then...
-
Three = 1
-
frmMachine.imgThree.Picture = LoadPicture("G:\crossblade.bmp")
-
End If
-
If RandomImage = 2 Then 'If image 2 is selected
-
Three = 2
-
frmMachine.imgThree.Picture = LoadPicture("G:\crosstown.bmp")
-
End If
-
If RandomImage = 3 Then 'If the random image is 1 then...
-
Three = 3
-
frmMachine.imgOne.Picture = LoadPicture("G:\hello yellow.bmp")
-
End If
-
If RandomImage = 4 Then 'If the random image is 1 then...
-
Three = 4
-
frmMachine.imgOne.Picture = LoadPicture("G:\h1.bmp")
-
End If
-
'Loop
-
-
If RandomCount = 30 Then
-
-
'Transfers values to frmMachine
-
frmMachine.One = One
-
frmMachine.Two = Two
-
frmMachine.Three = Three
-
-
Unload frmRandom
-
-
End If
-
-
End Sub
-
Sign in to post your reply or Sign up for a free account.
Similar topics
by: 1kHz |
last post by:
Hi all..
I'm new with this Ajax thingy and have done some experimenting. I did
some codes according to examples from
http://www.webpasties.com/xmlHttpRequest/
and...
|
by: carr4895 |
last post by:
Hello.
I was wondering if someone could help me too with a login form. Upon
startup, I have to display a password screen and it should accept a
user name and password. User name can be anything...
|
by: MingChih Tsai |
last post by:
Hi there,
Are there any slot machine c# sample codes for reference ?
Thanks !!
Best regards,
Paul
|
by: raishi |
last post by:
I am trying to figure out how to make a simple slot machine program in VBScript that starts by prompting and collecting the desired number of slot machine spins to simulate
simulates the spins:...
|
by: Oriane |
last post by:
Hi there,
I read that the .NET 3.5 Compact .net framework is in Beta.
What would you suggest to build from now on a new .NET client/server
application running on several Windows CE and a W2k3...
|
by: noob2008 |
last post by:
this code works but theres a problem wif it. wen it generates for 4 players, it has repeated values i.e 2 of diamond appear twice.
how do i avoid this?
and
i hav no idea how to program the...
|
by: Mike |
last post by:
I am a novice writing a simple program in Visual C++ Express and am
having an issue. I basically have several picture boxes of the same
size on top of each other with only one visible at a time. ...
|
by: dirtysouth6975 |
last post by:
I need some help. I am getting an error of: local function definitions are illegal. What does this mean? Can anybody help me out a little? Thank you.
//Specification: This program simulates a three...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| | |