Click here to Skip to main content
15,116,516 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have created a click event for 4 buttons click, where if a button is clicked it is added to a list called buttonslist. Now all I need to do is to check if the button with the highest index out of 4 backcolor is red or blue. (program - visual basic 2010)
What do you guys suggest me ?

What I have tried:

this is my code for this part :
VB.NET
Dim buttonList As New List(Of Button)

Private Sub buttons_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles b1.Click, b4.Click, b5.Click, b8.Click
    Dim selectedBtn As Button = sender
    buttonList.Add(selectedBtn)
End Sub

Public Sub checkitems()
    For Each b As Button In buttonList
        If b.BackColor.Equals(buttonList(3).BackColor) AndAlso buttonList(3).BackColor = Color.Red Then
            Label5.Text += 1
        Else
            Label6.Text += 1
        End If
    Next
End Sub
Posted
Updated 7-Apr-21 23:23pm
v2

1 solution

How about implementing some of the suggestions you have already been given at How can I sort my buttons in an array in order they are clicked in visual basic?[^].
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month