Jump to content
• Advertisement

Public Group

# VB6 what's wrong with this line?

This topic is 4807 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

## Recommended Posts

I have made a slot machine using vb6. There are 9 windows forming a 3x3 square in which random pictures appear. To test if there is a winning line of three symbols alike I use this. image8 is double bars image5 is single bar this line workd fine
If box(0) = Image1(8) And box(3) = Image1(8) And box(6) = Image1(8) Then payout4 = bet * 10

With this next line I want to check the same three boxes to see if either the single or double bar symbols are present. This line does not work. I have tries both or and xor. Do you know why? What should I write.
If box(0) = Image1(5) Xor box(0) = Image1(8) And box(3) = Image1(5) Xor box(3) = Image1(8) And box(6) = Image1(5) Xor box(6) = Image1(8) Then payout4 = bet * 1 And Text4.Text = bet * 1

I greatly would appreciate any and all imput. thanks

#### Share this post

##### Share on other sites
Advertisement
Try this:

[source lang = "vb"]If (box(0) = Image1(5) Or box(0) = Image1(8)) And (box(3) = Image1(5) Or box(3) = Image1(8)) And (box(6) = Image1(5) Or box(6) = Image1(8)) Then     payout4 = bet * 1 & Text4.Text End If

All I did was put parentheses around your seperate comparisons, changed the Xor to Or (Xor returns true if one and only one of the conditions is true. It returns false if they are both true or both false. If this is what you want, change them back to Xor.)
Then I changed your "And" in the "payout4..." line to "&" because that is the string concatinator(sp?) in VB, not the word "And". See if that works.

For future reference, it is helpful to let people know what the error message is (or what the problem is if it's a logic error). That makes it easier for us to help you.

#### Share this post

##### Share on other sites
nope darn it. That doesn't work either. hmm.

Thanks for the tips. I am not getting any error message but the lines of mixed bars are not paying.

#### Share this post

##### Share on other sites
This should work, provided that your condition is the following:

* It's only paying off if there's a bar of some sort (Single or double, it doesn't care) in each of the (0), (3), and (6) positions.

If this doesn't work as you want, perhaps you were asking for it to check the wrong positions... we can't see your code as far as what positions it's supposed to check, but indeed this code should do that (if that's what you wanted it to do: and it's similar to what the other guy was talking about, I just added extra parenthesis to be absolutely sure that the interpreter wasn't getting confused)

If     ((box(0) = Image1(5)) or (box(0) = Image1(8))) _   And ((box(3) = Image1(5)) or (box(3) = Image1(8))) _   And ((box(6) = Image1(5)) or (box(6) = Image1(8))) Then          payout4 = bet * 1          Text4.Text = bet * 1End If

I think part of the problem also was the strange way you were dealing with the "Then" clause... I've never tried doing a "Then" statement that way (with the "And" in it and all). I have no idea if that would work, but it's highly non-standard. If you use If in the way I describe above (well, without the _'s that I put in for clarification of what I was doing), you'll be able to see more clearly what you're asking the interpreter to do.

#### Share this post

##### Share on other sites
what kind of control is 'box'? I'm assuming Image1 is, indeed, an Image control.

#### Share this post

##### Share on other sites
box(0) through box(8) are a control aray of image controls. Everything is working A ok except the bar double bar line award.

Thanks for all of the help I do appreciate it greatly.

perhaps there is something else wrong but everything seems fine.

#### Share this post

##### Share on other sites
The problem was that I had the statement nested with another if condition put on it.

add one to my experience count.

thanks for the tips they will indeed be very useful.

#### Share this post

##### Share on other sites

• Advertisement

### Announcements

• Advertisement

• ### Popular Now

• 10
• 17
• 9
• 14
• 41
• Advertisement
• Advertisement
×

## Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!