sub of a event handler (dynamically generated, combobox, textbox, button)

558fe5180e0e8fc922d31c23ef84d240

Hi all, I have created an Event handler to a function for clicking a generated button, now when this button is clicked need to paste in a textbox the Combobox.seleteditem (that it's a string. Each generated one (Combobox, textbox, button) will have a selected index of the Combobox that it's different, but that is not the problem because I put it in an if, the issues it's that I can't put inside this sub all the three-component. After all, it tells me that the windows form button cannot be a textbox, etc. Do I need to put another two event handlers for textbox and Combobox? (The code below it's a workaround, but I Like to do this with a button)

Public Sub btn_Click(sender As System.Object, ByVal e As System.EventArgs)
        'Dim btn As New Button
        'btn = CType(sender, Button)
        'Dim txt As New TextBox
        'txt = CType(sender, TextBox)
        Dim cbx As New ComboBox
        cbx = CType(sender, ComboBox)
        TextBox4.Text += cbx.SelectedItem.ToString & vbCrLf
    End Sub

not displaying the union and intersection of sets in output

558fe5180e0e8fc922d31c23ef84d240
#include<iostream>
using namespace std;
class Sports
{
    public:
        int tennis;
        int badminton;
        int cricket;
        int setA[20],setB[20],setC[20];
        int ab[20],bc[20],ca[20],abc[20];
        int n1,n2,n3,n4=0,total;
        void accept();  // method for accept the input
        void intersection();    //method for calculate intersection
        void display(); //method for display intersections
};
void Sports :: accept()
{
    cout<<"Enter the total number of players who play Tennis: "<<endl;
    cin>>tennis;
    cout<<"Enter the student roll no who play Tennis "<<endl;
    for(int i=0; i<tennis; i++)
        cin>>setA[i];

    cout<<"Enter the total number of players who play Badminton: "<<endl;
    cin>>badminton;
    cout<<"Enter the student roll no who play Badminton "<<endl;
    for(int i=0; i<badminton; i++)
        cin>>setB[i];

    cout<<"Enter the total number of players who play cricket: "<<endl;
    cin>>cricket;
        cout<<"Enter the student roll no who play cricket "<<endl;
    for(int i=0; i<cricket; i++)
        cin>>setC[i];

}
void Sports :: intersection()
{
    // Logic for intersection SET-A and SET-B

    for(int i=0;i<cricket;i++)
    {
         for(int j=0;j<badminton;j++)
         {
            if(setA[i]==setB[j])
            {
                ab[n1]=setA[i];
                n1++;
            }
         }  
    }

    // Logic for intersection SET-B and SET-C
    for(int i=0;i<badminton;i++)
    {
         for(int j=0;j<cricket;j++)
         {
            if(setB[i]==setC[j])
            {
                bc[n2]=setB[i];
                n2++;
            }
         }  
    }
    // Logic for intersection SET-C and SET-A
    for(int i=0;i<cricket;i++)
    {
         for(int j=0;j<tennis;j++)
         {
            if(setC[i]==setA[j])
            {
                ca[n3]=setC[i];
                n3++;
            }
         }  
    }
    //logic for A union B union C
    for(int i=0;i<tennis;i++)
    {
         for(int j=0;j<badminton;j++)
         {
            for(int k=0;k<cricket; k++)
            {
                if(setA[i]==setB[j] && setA[i]==setC[k])
                {
                    abc[n4]=setA[i];
                    n4++;
                }
            }
         }  
    }
   total=tennis+badminton+cricket-n1-n2-n3+n4;  
}
void Sports :: display()
{
    //logic for print intersection of tennis and Badminton
    cout<<"\nIntersection of SET-A and SET-B: ";
    for(int i=0; i<n1; i++)
        cout<<ab[i]<<" ";

    //logic for print intersection of Badminton and Cricket  
    cout<<"\nIntersection of SET-B and SET-C: ";
    for(int i=0; i<n2; i++)
        cout<<bc[i]<<" ";

    //logic for print intersection of Cricket and Tennis
    cout<<"\nIntersection of SET-C and SET-A: ";
    for(int i=0; i<n3; i++)
        cout<<ca[i]<<" ";

    // logic for print intersection of Tennis and Badminton and Cricket
    cout<<"\nIntersection of SET-A and SET-B and SET-C: ";
    for(int i=0; i<n4; i++)
        cout<<abc[i]<<" ";

    // logic for print total number of students in a class
    cout<<"\nTotal number of students in class are : "<<total;
}
int main()
{
    Sports s;
    s.accept();
    s.intersection();
    s.display();
    return 0;
}

pll.png