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

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Arizonasworld85
    New Member
    • Apr 2022
    • 1

    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.
  • MerlinTheGreat
    New Member
    • Jun 2022
    • 6

    #2
    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.

    Code:
    d = a + b + c
    
    Select Case d
      Case = 2 : two of the variables a, b and c have a value of 1
         : Do whatever is needed to be done in this case.
    
      Case = 4 : two of the variables a, b and c have a value of 2
         : Do whatever is needed to be done in this case.
    
      Case = 8 : two of the variables a, b and c have a value of 4
         : Do whatever is needed to be done in this case.
    
      : If other combined values are to be checked,
      : you can put them here in the same way as the code above
    
      Case Else : Catch all for other combinations
         : Do whatever is needed to be done in this case.
    
    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.

    Comment

    Working...