Well maybe it's because the first time you come to the first statement in the loop intDie12 and intDie34 hasn't got any values so they are both 0. Meaning you will never enter the loop since intDie12 = intDie34. You could change the loop to:
Well consider the code you have inside the loop. You never change the values of intDie1 - 4. So maybe intDie12 never will equal intDie34 meaning you end up with an endless loop.
The loop never runs at all. I ran a break and it skipped over the loop when I got there. the Die3(intDie3 - 1).Visible = True part makes the picture of a die show up, and no dice even show up. There is obviously something wrong and I'm not sure what it is...
I have six images of the six sides of a die. Each are name Dice1(0) for the 1 side, Dice2(1) for the two side etc. etc. This Dice3(intDie3 - 1).Visible = True makes whatever number this intDie3 = Rand(1, 6) generates to make that die show up.
I can when I get home I'm at school right now and their computers are very limited. There's no winzip. I'll post it around 6 tonight. I'll prolly make a new thread. Thanks cya.
May I ask what it actually means when you have, let's say rolled a 9 and the MsgBox comes up just before the loop that says "Roll to match 9" means? Are you supposed to hit the roll button until the two new dices also show 9? That is not happening now, the only thing that happens is that the loop keeps going until you've reached 9 on the two other dices. Of course this is not shown since you never put the last two dices on top of the others.
VB Code:
Do
intDie3 = Rand(1, 6)
intDie4 = Rand(1, 6)
DoEvents
Dice3(intDie3 - 1).Visible = True
Dice4(intDie4 - 1).Visible = True
Dice3(intDie3 - 1).ZOrder 'Put this dice upon any earlier shown dice
Dice4(intDie4 - 1).ZOrder 'Put this dice upon any earlier shown dice
intDie12 = intDie1 + intDie2
intDie34 = intDie3 + intDie4
If intDie12 = intDie34 Then
'lblWinner.Visible = True
lblAmount.Caption = "Player's Total Money: $" & intAmount
End If
Loop Until intDie12 = intDie34
As you can see I added a call using ZOrder that will bring the new dice to the top of the others. But this loop will go so fast that you will hardly see anything but the fact that the two new dices also show 9 together.
May I also suggest that you make a call to Randomize in Form_Load.
VB Code:
Private Sub Form_Load()
Randomize
End Sub
So you don't get the same random numbers every time you play.
Mr. Joacim, my teacher's version of the dice move very quickly on the second pair of dice, so that is good . The point of the roll to match, is that when you don't get a 2, 7, 11, or 12, whatever you roll (say a 3 and 6) that will be 9. So on the second pair of dice you have to match 9 (in any combination) or get a 7 or 11 which in the second roll, will make you lose.
No, on the first roll if you don't roll a 2 (snake eyes ) 7, 11, or 12, then you get a 'subsequent roll' which is the second pair of dice. You roll as many times with the second pair of dice until you match your first roll's total or get a 7 or 11.
Wow, that works perfectly. I don't get why you had to have the Zorder tho?
Say your first two dice show a 6 and a 3. That means you must match 9 on the other two, right? So let's say in the first round of the loop they come up as 3 and 2. Those two images are now visible. Let's say next time they come up as 1 and 4 which of them are then the two topmost images? 3 and 2 or 1 and 4? Or maybe 3 and 4 or 1 and 2? The images is on top of each other when you start the game some are on top of others. If you are showing two images that are of the exact same size and at the exact same position you will of course only see one of them. The one on the top. Setting the ZOrder (without any argument) will bring the object to top.
That's is not necassary since you set their Visible property to False at the start of the Sub. So only two images will be visible at any time, the two that shows the randomly selected numbers. But inside the Loop you set the Visible property for Dice3 and Dice4 but never set it back to False.