Public Class Form1 For Each c As Control In Panel1.Controls If c.GetType() = GetType(Button) Then AddHandler c.Click, AddressOf btn_Click End If Next End Sub Dim Xor0 As Integer = 0 Public Sub btn_Click(ByVal sender As Object, ByVal e As EventArgs) Dim btn As Button = sender If btn.Text.Equals("") Then If Xor0 Mod 2 = 0 Then btn.BackColor = Color.Blue Label1.Text = ply2 + "'s Turn" Else btn.BackColor = Color.Red Label1.Text = ply1 + "'s Turn" End If Xor0 = Xor0 + 1 End If End Sub End Class
sender
Dim clickedButtons As List(Of Button) = New List(Of Button)()
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)