424,946 Members | 712 Online
Need help? Post your question and get tips & solutions from a community of 424,946 IT Pros & Developers. It's quick & easy.

# Limit dice rolls? Add points when clicking a "dice" as background Image on button?

 P: 2 I have to do a project where there are 5 die, and each player gets 3 rolls per turn. The player then hits cmdPlayer1Roll, which randomizes the die 1-5. The player can randomize the die 3 time but at the end of the 3 rolls they need to have selected 3 numbers from the die. The first player to 1000 wins. I have to what i believe, successfully coded the randomize on the click of cmdPlayer1roll. Here is a very fast gyazo gif of what i have coded overall, http://gyazo.com/0dfe67c781a8cec7ce629db303deb59e This is the code i used for randomize: (repeated 5 times, 5 dice button boxes/5 dice to roll 3 times) Expand|Select|Wrap|Line Numbers         'randomize cmdDice1 background image         Call Randomize()         lowernum = 1         upperNum = 6         die1 = Int(Rnd() * (upperNum - lowernum + 1)) + lowernum         If die1 = 1 Then             cmdDice1.BackgroundImage = My.Resources.dice1Dot         ElseIf die1 = 2 Then             cmdDice1.BackgroundImage = My.Resources.dice2Dot1           ElseIf die1 = 3 Then             cmdDice1.BackgroundImage = My.Resources.dice3Dot         ElseIf die1 = 4 Then             cmdDice1.BackgroundImage = My.Resources.dice4Dot         ElseIf die1 = 5 Then             cmdDice1.BackgroundImage = My.Resources.dice5Dot         ElseIf die1 = 6 Then             cmdDice1.BackgroundImage = My.Resources.dice6Dot         End If   I have 2 issues, here they are: 1.) I am struggling to determine where and how to add in the limit of rolls. Today i just learned counters, though i do not know how to go about saying a buttonclick is a roll. Here is my attempt Expand|Select|Wrap|Line Numbers   Private Sub cmdPlayer1Roll_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdPlayer1Roll.Click           'Attempt at limiting rolls to 3 for player 1          lowernum = 1         upperNum = 6         roll = 1         rollsleft = 3         rollsleft = rollsleft - roll         If rollsleft = 0 Then             cmdPlayer1Roll.Enabled = False         End If 2.) i have made no progress on figuring out how to make the buttons add the amount of dots the randomized picture in the box has, my teacher, did try to explain that when i wrote the randomize code i included part of it, but as i am a unit ahead of my class she had no time to explain it to me. Thanks for any of the help i will get, it is very much appreciated. Oct 23 '14 #1