473,372 Members | 805 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,372 software developers and data experts.

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

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 16616
6 Nibble
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
  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.
  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.
  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.
  13.   : If other combined values are to be checked,
  14.   : you can put them here in the same way as the code above
  16.   Case Else : Catch all for other combinations
  17.      : Do whatever is needed to be done in this case.
  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

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...
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: 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...
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: 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...
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: 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...
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);
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...
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...
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.