I am trying to make a small game in which the computer gives a random code of colours (red green yellow and blue) and then you must try and guess them... I am having trouble making the colours random though.
The colours are the backcolour of 4 buttons. The code is four colours long. The player then clicks on some buttons just below that and tries to guess the code. Each click changes the colour once. If the player guesses the correct colour which is in the correct place then the colour is revealed.
So far I have this:
(Problem is : Overload resolution failed because no Public '=' can be called with these arguments:'Public Shared Operator =(left As System.Drawing.Color, right As System.Drawing.Color) As Boolean': Argument matching parameter 'right' cannot convert from 'Integer' to 'Color'. (See below REM color 1 to REM End) Problem was generated by the computer , program written in Visual Basic , windows form application)
Dim turn = 0
Dim generator As New Random
Dim color1 = generator.Next(1, 4)
Dim color2 = generator.Next(1, 4)
Dim color3 = generator.Next(1, 4)
Dim color4 = generator.Next(1, 4)
Private Sub NewToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NewToolStripMenuItem.Click
REM color 1
If color1 = 1 Then
color1 = Color.Red
End If
If color1 = 2 Then
color1 = Color.Blue
End If
If color1 = 3 Then
color1 = Color.Yellow
End If
If color1 = 4 Then
color1 = Color.Green
End If
REM color 2
If color2 = 1 Then
color2 = Color.Red
End If
If color2 = 2 Then
color2 = Color.Blue
End If
If color2 = 3 Then
color2 = Color.Yellow
End If
If color2 = 4 Then
color2 = Color.Green
End If
REM color 3
If color3 = 1 Then
color3 = Color.Red
End If
If color3 = 2 Then
color3 = Color.Blue
End If
If color3 = 3 Then
color3 = Color.Yellow
End If
If color3 = 4 Then
color3 = Color.Green
End If
REM color 4
If color4 = 1 Then
color4 = Color.Red
End If
If color4 = 2 Then
color4 = Color.Blue
End If
If color4 = 3 Then
color4 = Color.Yellow
End If
If color4 = 4 Then
color4 = Color.Green
End If
REM End
Button1.BackColor = color1
Button2.BackColor = color2
Button3.BackColor = color3
Button4.BackColor = color4