Hopefully this will make sense, but I am creating this 'board' type game where there is a die and twenty-eight labels, which I have made the labels into small squares and next to each other.
I need to figure out code which will automatically light up (change the BackColor) of the labels, based on the number generated by the die, which the player clicks on.
For example, when the player clicks the die a number is generated (1 - 6) and this is how many labels light up, and continues till all labels BackColor has changed to a different colour, e.g. green.
Code for die:
Private Sub imgDie_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles imgDie.Click
My.Computer.Audio.Play(My.Resources.Dice, AudioPlayMode.Background)
randomNumber = rand.Next(1, 7)
If randomNumber = 1 Then
imgDie.Image = My.Resources.Die_One
ElseIf randomNumber = 2 Then
imgDie.Image = My.Resources.Die_Two
ElseIf randomNumber = 3 Then
imgDie.Image = My.Resources.Die_Three
ElseIf randomNumber = 4 Then
imgDie.Image = My.Resources.Die_Four
ElseIf randomNumber = 5 Then
imgDie.Image = My.Resources.Die_Five
ElseIf randomNumber = 6 Then
imgDie.Image = My.Resources.Die_Six
End If
End Sub
So, what could I do to make sure the correct number of labels BackColor are changed? Would I need a function? Also, as the die is clicked numerous amount of times, labels are going to light up, so how do I get it so that those that haven't changed, are until all twenty-eight labels BackColor has changed?
I hope that this makes some sense?
The labels are named:
lblSquareOne, lblSquareTwo, lblSquareThree right through to lblSquareTwentyeight