You are on page 1of 2

Public Class Form1

Dim color1 As String


Dim color2 As String
Dim color3 As String
Dim Rand As New Random()
Dim Colors = New String() {"R", "G", "B", "Y"}
Dim Index As Integer = Rand.Next(0, Colors.Length - 1)
Dim colorscorrect As Integer
Dim positionscorrect As Integer

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles Button1.Click
positionscorrect = 0
colorscorrect = 0

If TextBox1.Text.Equals("R") And color1.Equals("R") Then


positionscorrect = positionscorrect + 1

End If

If TextBox1.Text.Equals("G") And color1.Equals("G") Then


positionscorrect = positionscorrect + 1
End If

If TextBox1.Text.Equals("B") And color1.Equals("B") Then


positionscorrect = positionscorrect + 1

End If

If TextBox1.Text.Equals("Y") And color1.Equals("Y") Then


positionscorrect = positionscorrect + 1

End If

If TextBox2.Text.Equals("R") And color2.Equals("R") Then


positionscorrect = positionscorrect + 1
End If

If TextBox2.Text.Equals("G") And color2.Equals("G") Then


positionscorrect = positionscorrect + 1

End If

If TextBox2.Text.Equals("B") And color2.Equals("B") Then


positionscorrect = positionscorrect + 1

End If

If TextBox2.Text.Equals("Y") And color2.Equals("Y") Then


positionscorrect = positionscorrect + 1

End If

If TextBox3.Text.Equals("R") And color3.Equals("R") Then


positionscorrect = positionscorrect + 1

End If
If TextBox3.Text.Equals("G") And color3.Equals("G") Then
positionscorrect = positionscorrect + 1

End If

If TextBox3.Text.Equals("B") And color3.Equals("B") Then


positionscorrect = positionscorrect + 1

End If

If TextBox3.Text.Equals("Y") And color3.Equals("Y") Then


positionscorrect = positionscorrect + 1

End If

Dim all As String


all = color1 + color2 + color3

If all.Contains(TextBox1.Text) Then
colorscorrect = colorscorrect + 1
End If

If all.Contains(TextBox2.Text) Then
colorscorrect = colorscorrect + 1
End If

If all.Contains(TextBox3.Text) Then
colorscorrect = colorscorrect + 1
End If

If positionscorrect = 3 And colorscorrect = 3 Then


MessageBox.Show("Winner!", "Correct!")
End If
Label4.Text = colorscorrect
Label5.Text = positionscorrect
Label6.Text = all

End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles MyBase.Load
color1 = Colors(Index)
Index = Rand.Next(0, Colors.Length - 1)
color2 = Colors(Index)
Index = Rand.Next(0, Colors.Length - 1)
color3 = Colors(Index)
colorscorrect = 0
positionscorrect = 0

End Sub
End Class

You might also like