473,657 Members | 2,693 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Need help I'm working on a slot machine game and need some help

1 New Member
I am working on a slot machine project in vb6. I am trying to figure out how to change this:

If (a = 1 And b = 1 And c <> 1) Or (a = 1 And c = 1 And b <> 1) Or (b = 1 And c = 1 And a <> 1) Or _
(a = 2 And b = 2 And c <> 2) Or (a = 2 And c = 2 And b <> 2) Or (b = 2 And c = 2 And a <> 2) Or _
(a = 4 And b = 4 And c <> 4) Or (a = 4 And c = 4 And b <> 4) Or (b = 4 And c = 4 And a <> 4) Or _
(a <> 1 And b = 1 And c = 1) Or (b <> 1 And c = 1 And a = 1) Or (c <> 1 And b = 1 And a = 1) Or _
(a <> 2 And b = 2 And c = 2) Or (b <> 2 And c = 2 And a = 2) Or (c <> 2 And b = 2 And a = 2) Or _
(a <> 4 And b = 4 And c = 4) Or (b <> 4 And c = 4 And a = 4) Or (c <> 4 And b = 4 And a = 4) Then

into a select case statement if possible. I am very new to programming but have come a good way. I am using the Rnd function to come up with 3 random numbers which associates itself to 3 different pictures out of 30 pictures. The problem is that when I program all the losing numbers to deduct money or whatever that there's to many combinations of the above code to put in an If Then statement. Would anybody have a suggestion or show me the way I would put it in a select case statement? I got the slot machine game to work good but it misses a majority because I don't know how to catch them all properly.
Apr 2 '22 #1
1 16712
MerlinTheGreat
6 New Member
Actually you wrote the same thing twice.
The first three lines are essentially the same as the other three lines, only in the opposite order of comparison.
Removing the 4th to the 6th line makes things easier since half of the code is dropped.

You could try to add the values of a, b and c together in a variable d and build a select case with the resulting value.
I'm not using the dim statement in this example. Doing so will however make your code clearer and less prone to errors.

Expand|Select|Wrap|Line Numbers
  1. d = a + b + c
  2.  
  3. Select Case d
  4.   Case = 2 : two of the variables a, b and c have a value of 1
  5.      : Do whatever is needed to be done in this case.
  6.  
  7.   Case = 4 : two of the variables a, b and c have a value of 2
  8.      : Do whatever is needed to be done in this case.
  9.  
  10.   Case = 8 : two of the variables a, b and c have a value of 4
  11.      : Do whatever is needed to be done in this case.
  12.  
  13.   : If other combined values are to be checked,
  14.   : you can put them here in the same way as the code above
  15.  
  16.   Case Else : Catch all for other combinations
  17.      : Do whatever is needed to be done in this case.
  18.  
  19. End Select
You might have to watch out for possible combinations that might give an unwanted match like a=1 b=1 c=2 which gives 4 as a result.
I don't know if this is possible in your programm.

I hope this helps you out.
Jun 13 '22 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
1519
by: Jarrod Hyder | last post by:
Ok, I wrote my own weblog and I'm working on the web interface for adding/editing my posts. I decided to add a little preview button...when the button is clicked it is suppose to open a pop-up window. I wrote the whole preview function in javascript so that I don't have to reload the page to see a preview. Here is the code I wrote that doesn't work at all: Code:
15
2278
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 non-blank. If there is no user name, an appropriate error message must be displayed. All of the following passwords are valid IT160, VB2Manager, BackDoor. No other password is valid. It must allow the user to enter the password in any case. If...
1
5675
by: peterggmss | last post by:
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...
3
3213
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 points system. so numbers from 2 to 10 worth zero points, jack = 1 pt, queen = 2 pts, king = 3 pts, ace = 4pts can ne1 help me to start the coding for teh points system as well?
1
2818
by: twin2003 | last post by:
need help with inventory part 5 here is what I have to do Modify the Inventory Program by adding a button to the GUI that allows the user to move to the first item, the previous item, the next item, and the last item in the inventory. If the first item is displayed and the user clicks on the Previous button, the last item should display. If the last item is displayed and the user clicks on the Next button, the first item should display. the...
7
27363
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 //wheeled slot machine. Each wheel will randomly //display three numbers. When the numbers on the //wheels match the user is award points. The Slot //machine requires the user to enter tokens to play. #include <iostream> #include <ctime> ...
28
1800
by: G8tors | last post by:
I have a fantasy football league that I am keeping stats for in an Access Database. I need help coming up with a way to calclulate the winning % for each team for their entire career. What I have is a table with the following fields: Fantasy Team Season Week W/L Own Score Vs Opponent Opponent Score Game type
4
1469
by: bossy | last post by:
#include<stdlib.h> #include<stdio.h> #include<iostream> #include<string> using namespace std; double getDouble(char prompt); int getchar(char prompt); void printReport(int);
0
11557
Random777
by: Random777 | last post by:
This all started when I first wanted to make a slot machine video game and had some other ideas to try out as well. This is a code and information collection you can use to create various slot machine effects. Mostly, the idea is to provide different effects using HTML5, CSS3, and/or JQuery to produce the spinning wheel(s) and some other effects. The problems show up often while trying to get the animations to appear properly. It’s not...
6
1079
by: terryechols1 | last post by:
I'm having a major brain collapse on this issue. I have tried everything I can think of but it won't behave the way I want it to. This problem, I'm hoping someone can help me out with, involves 2 forms and 1 table. The first form (Call Details) has a tab for "Related Calls". The purpose of this is to relate calls to one another - for us showing a history of a service call for an appliance. We then group calls for the address based on the...
0
8403
marktang
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
8509
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7345
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6174
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5636
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4168
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2735
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1967
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1730
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.