'1つのプロシージャで複数のコントロールのイベントをハンドルする Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _ Handles Button1.Click, Button2.Click, Button3.Click Select Case sender.name Case "Button1" Timer1.Enabled = False Call Judge(Timer2, Timer3) Case "Button2" Timer2.Enabled = False Call Judge(Timer1, Timer3) Case "Button3" Timer3.Enabled = False Call Judge(Timer1, Timer2) End Select End Sub Private Sub Judge(ByVal pT1 As Windows.Forms.Timer, ByVal pT2 As Windows.Forms.Timer) If pT1.Enabled = False And pT2.Enabled = False Then Button4.Enabled = True If x = y And y = z Then TextBox1.Text = "的中!" m = m + 50 TextBox2.Text = m Else TextBox1.Text = "残念" End If End If End Sub
'私はこの程度なら此方が好みです。 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Timer1.Enabled = False Call Judge(Timer2, Timer3) End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Timer2.Enabled = False Call Judge(Timer1, Timer3) End Sub Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click Timer3.Enabled = False Call Judge(Timer1, Timer2) End Sub 'この関数は上のと同じもんです。 Private Sub Judge(ByVal pT1 As Windows.Forms.Timer, ByVal pT2 As Windows.Forms.Timer) If pT1.Enabled = False And pT2.Enabled = False Then Button4.Enabled = True If x = y And y = z Then TextBox1.Text = "的中!" m = m + 50 TextBox2.Text = m Else TextBox1.Text = "残念" End If End If End Sub