james_h
Member
- Joined
- Aug 21, 2012
- Messages
- 15
- Programming Experience
- Beginner
Hi Guys,
I am trying to make a dice roller that generates a random number which is all good.
The problem I am having is at the start of the code the picturebox should display a series of images
before finishing on the random number. I have a half second delay between displayed images, the delay is working
but the images are not displayed between each half second delay. After the delay time then the random number is displayed correctly???
Thanks for looking.
I am trying to make a dice roller that generates a random number which is all good.
The problem I am having is at the start of the code the picturebox should display a series of images
before finishing on the random number. I have a half second delay between displayed images, the delay is working
but the images are not displayed between each half second delay. After the delay time then the random number is displayed correctly???
Public Class frmDiceRoll Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRollDice.Click Dim diceroll As Integer Dim DiceNumber As System.Random 'scroll through several different images with a half second delay between each image picRollDice.BackgroundImage = My.Resources.dice_3 System.Threading.Thread.Sleep(500) picRollDice.BackgroundImage = My.Resources.dice_6 System.Threading.Thread.Sleep(500) picRollDice.BackgroundImage = My.Resources.dice_4 System.Threading.Thread.Sleep(500) picRollDice.BackgroundImage = My.Resources.dice_1 System.Threading.Thread.Sleep(500) picRollDice.BackgroundImage = My.Resources.dice_2 System.Threading.Thread.Sleep(500) picRollDice.BackgroundImage = My.Resources.dice_1 System.Threading.Thread.Sleep(500) picRollDice.BackgroundImage = My.Resources.dice_5 System.Threading.Thread.Sleep(500) picRollDice.BackgroundImage = My.Resources.dice_6 System.Threading.Thread.Sleep(500) picRollDice.BackgroundImage = My.Resources.dice_1 System.Threading.Thread.Sleep(500) picRollDice.BackgroundImage = My.Resources.dice_4 System.Threading.Thread.Sleep(500) picRollDice.BackgroundImage = My.Resources.dice_5 'generate a random number between 1-6 and store in diceroll DiceNumber = New System.Random(My.Computer.Clock.TickCount) diceroll = CInt(DiceNumber.Next(1, 7)) 'display image based on dicerolls value Select Case diceroll Case 1 picRollDice.BackgroundImage = My.Resources.dice_1 Case 2 picRollDice.BackgroundImage = My.Resources.dice_2 Case 3 picRollDice.BackgroundImage = My.Resources.dice_3 Case 4 picRollDice.BackgroundImage = My.Resources.dice_4 Case 5 picRollDice.BackgroundImage = My.Resources.dice_5 Case 6 picRollDice.BackgroundImage = My.Resources.dice_6 End Select End Sub End Class
Thanks for looking.