c# – How could i get a numerical value into a different form, the selectt int

public partial class popup : Form
{
    
    public popup()
    {
        InitializeComponent();
        
        
        


    }
    
    public void button1_Click(object sender, EventArgs e)
    {

        if (textBox1.Text == "1")
        {
            selectt = 1;
        }
        else if (textBox1.Text =="11")
        {
            selectt = 11;
        }
        else
        {
            MessageBox.Show("Please enter a number 1 or 11!!");
        }
        Close();
    }
    public static int selectt { get; set; }
    
      
}

}

This was the code for the popup form which prompts the user to input a 1 or an 11 to chose the value for an ace. however it wont input to my other form can someone please try and help me figure out where it is not going through?

namespace DealCard

{ public partial class Form1 : Form { public Form1() { InitializeComponent(); } //creates a seed number that willbe used in the dealcard method so //it returns different card values ​​int seednum = (int)DateTime.Now.Ticks;

    public void Form1_Load(object sender, EventArgs e)
    {
        //Adds all 52 cards pictures to the image list
        CardPicList.Add(Properties.Resources._1);
        CardPicList.Add(Properties.Resources._2);
        CardPicList.Add(Properties.Resources._3);
        CardPicList.Add(Properties.Resources._4);
        CardPicList.Add(Properties.Resources._5);
        CardPicList.Add(Properties.Resources._6);
        CardPicList.Add(Properties.Resources._7);
        CardPicList.Add(Properties.Resources._8);
        CardPicList.Add(Properties.Resources._9);
        CardPicList.Add(Properties.Resources._10);
        CardPicList.Add(Properties.Resources._11);
        CardPicList.Add(Properties.Resources._12);
        CardPicList.Add(Properties.Resources._13);
        CardPicList.Add(Properties.Resources._14);
        CardPicList.Add(Properties.Resources._15);
        CardPicList.Add(Properties.Resources._16);
        CardPicList.Add(Properties.Resources._17);
        CardPicList.Add(Properties.Resources._18);
        CardPicList.Add(Properties.Resources._19);
        CardPicList.Add(Properties.Resources._20);
        CardPicList.Add(Properties.Resources._21);
        CardPicList.Add(Properties.Resources._22);
        CardPicList.Add(Properties.Resources._23);
        CardPicList.Add(Properties.Resources._24);
        CardPicList.Add(Properties.Resources._25);
        CardPicList.Add(Properties.Resources._26);
        CardPicList.Add(Properties.Resources._27);
        CardPicList.Add(Properties.Resources._28);
        CardPicList.Add(Properties.Resources._29);
        CardPicList.Add(Properties.Resources._30);
        CardPicList.Add(Properties.Resources._31);
        CardPicList.Add(Properties.Resources._32);
        CardPicList.Add(Properties.Resources._33);
        CardPicList.Add(Properties.Resources._34);
        CardPicList.Add(Properties.Resources._35);
        CardPicList.Add(Properties.Resources._36);
        CardPicList.Add(Properties.Resources._37);
        CardPicList.Add(Properties.Resources._38);
        CardPicList.Add(Properties.Resources._38);
        CardPicList.Add(Properties.Resources._40);
        CardPicList.Add(Properties.Resources._41);
        CardPicList.Add(Properties.Resources._42);
        CardPicList.Add(Properties.Resources._43);
        CardPicList.Add(Properties.Resources._44);
        CardPicList.Add(Properties.Resources._45);
        CardPicList.Add(Properties.Resources._46);
        CardPicList.Add(Properties.Resources._47);
        CardPicList.Add(Properties.Resources._48);
        CardPicList.Add(Properties.Resources._49);
        CardPicList.Add(Properties.Resources._50);
        CardPicList.Add(Properties.Resources._51);
        CardPicList.Add(Properties.Resources._52);

        //Adds the first 4 card values which are aces to the card value list
        CardValueList.Add(11);
        CardValueList.Add(11);
        CardValueList.Add(11);
        CardValueList.Add(11);
        //Adds the next 4 card values which are Kings to the card value list
        CardValueList.Add(10);
        CardValueList.Add(10);
        CardValueList.Add(10);
        CardValueList.Add(10);
        //Adds the next 4 card values which are queens to the card value list
        CardValueList.Add(10);
        CardValueList.Add(10);
        CardValueList.Add(10);
        CardValueList.Add(10);

        //Adds the next 4 card values which are Jacks to the card value list
        CardValueList.Add(10);
        CardValueList.Add(10);
        CardValueList.Add(10);
        CardValueList.Add(10);

        //Adds the next 4 card values which are 10s to the card value list
        CardValueList.Add(10);
        CardValueList.Add(10);
        CardValueList.Add(10);
        CardValueList.Add(10);

        //Adds the next 4 card values which are 9s to the card value list
        CardValueList.Add(9);
        CardValueList.Add(9);
        CardValueList.Add(9);
        CardValueList.Add(9);

        //Adds the next 4 card values which are 8s to the card value list
        CardValueList.Add(8);
        CardValueList.Add(8);
        CardValueList.Add(8);
        CardValueList.Add(8);

        //Adds the next 4 card values which are 7s to the card value list
        CardValueList.Add(7);
        CardValueList.Add(7);
        CardValueList.Add(7);
        CardValueList.Add(7);

        //Adds the next 4 card values which are 6s to the card value list
        CardValueList.Add(6);
        CardValueList.Add(6);
        CardValueList.Add(6);
        CardValueList.Add(6);

        //Adds the next 4 card values which are 5s to the card value list
        CardValueList.Add(5);
        CardValueList.Add(5);
        CardValueList.Add(5);
        CardValueList.Add(5);

        //Adds the next 4 card values which are 4s to the card value list
        CardValueList.Add(4);
        CardValueList.Add(4);
        CardValueList.Add(4);
        CardValueList.Add(4);

        //Adds the next 4 card values which are 3s to the card value list
        CardValueList.Add(3);
        CardValueList.Add(3);
        CardValueList.Add(3);
        CardValueList.Add(3);

        //Adds the next 4 card values which are 2s to the card value list
        CardValueList.Add(2);
        CardValueList.Add(2);
        CardValueList.Add(2);
        CardValueList.Add(2);

    }
    //Defines a image list to store the picture of the cards
    List<Image> CardPicList = new List<Image>();

    //Defines a corresponding list to hold the value of the cards
    List<int> CardValueList = new List<int>();
    //Creates Player Card Values
    int cardValue1 = 0;
    int cardValue2 = 0;
    int cardValue3 = 0;
    int cardValue4 = 0;
    int cardValue5 = 0;


    ///Creates Dealer Card Value
    int cardValue1Deal = 0;
    int cardValue2Deal = 0;
    int cardValue3Deal = 0;
    int cardValue4Deal = 0;
    int cardValue5Deal = 0;


    //Creates Ints For Random Cards
    int randomCard1 = 0;
    int randomCard2 = 0;
    int randomCard3 = 0;
    int randomCard4 = 0;
    int randomCard5 = 0;
    int randomCard6 = 0;
    int randomCard7 = 0;
    int randomCard8 = 0;
    int randomCard9 = 0;
    int randomCard10 = 0;
    ///Creates Totals
    int playertot = 0;
    int dealertot = 0;



    public void btnDeal_Click(object sender, EventArgs e)
    {
        //gets 10 random numbers from the dealcard method
        randomCard1 = DealCard();
        randomCard2 = DealCard();
        randomCard3 = DealCard();
        randomCard4 = DealCard();
        randomCard5 = DealCard();
        randomCard6 = DealCardDeal();
        randomCard7 = DealCardDeal();
        randomCard8 = DealCardDeal();
        randomCard9 = DealCardDeal();
        randomCard10 = DealCardDeal();

        //assigns values to the two cards from the Card value List
        cardValue1 = CardValueList[randomCard1];
        cardValue2 = CardValueList[randomCard2];
        cardValue3 = CardValueList[randomCard3];
        cardValue4 = CardValueList[randomCard4];
        cardValue5 = CardValueList[randomCard5];


        cardValue1Deal = CardValueList[randomCard6];
        cardValue2Deal = CardValueList[randomCard7];
        cardValue3Deal = CardValueList[randomCard8];
        cardValue4Deal = CardValueList[randomCard9];
        cardValue5Deal = CardValueList[randomCard10];
        dealertot += cardValue1Deal;
        txbxdt.Text = dealertot.ToString();

        //Adds Exception To Count Ace as 10 or 11
        if (cardValue1 == 11)
        {

            popup select = new popup();
            select.Show();
            cardValue1 = popup.selectt;
            playertot += cardValue1;
            txbxpt.Text = playertot.ToString();



        }
        else
        {
            playertot+=cardValue1;
            txbxpt.Text = playertot.ToString();
        }
        //assigns pictures to the card from the Card picture List
        picBoxP1.Image = CardPicList[randomCard1];
        picBoxD1.Image = CardPicList[randomCard6];
    }
    public int DealCard()
    {
        int mynumber;
        Random randy1 = new Random(seednum);
        mynumber = randy1.Next(52);
        seednum += 100;
        return mynumber;
    }
    public int DealCardDeal()
    {
        int mynumber;
        Random randy2 = new Random(seednum);
        mynumber = randy2.Next(52);
        seednum += 200;
        return mynumber;
    }

    
    public void Hit_Click(object sender, EventArgs e)
    {           
        for (int count = 0; count <=2; count++)
        {
            
            popup select = new popup();
            
            if (playertot <= 21)
            { 
                
                if (count == 0)
                {

                    picBoxP3.Image = CardPicList[randomCard3];
                    if (cardValue3 == 11)
                    {

                        select.Show();
                        cardValue3 = popup.selectt;
                        playertot.ToString();
                        playertot += cardValue3;
                        txbxpt.Text = playertot.ToString();
                        
                    }
                    else
                    {
                        playertot.ToString();
                        playertot+=cardValue3;
                        txbxpt.Text = playertot.ToString();
                        
                    }
                    
                }
                else if (count == 1)
                {

                    picBoxP4.Image = CardPicList[randomCard4];
                    if (cardValue4 == 11)
                    {
                        select.Show();
                        cardValue4 = popup.selectt;
                        playertot.ToString();
                        playertot += cardValue4;
                        txbxpt.Text = playertot.ToString();
                    }
                    else
                    {
                        playertot+=cardValue4;
                        txbxpt.Text = playertot.ToString();
                    }
                    
                }
                else if (playertot >= 21)
                {

                    MessageBox.Show("Sorry You have lost please try again!");


                }                    
                else if (count == 2)
                {
                    picBoxP5.Image = CardPicList[randomCard5];
                    if (cardValue5 == 11)
                    {

                        
                        select.Show();
                        cardValue5 = popup.selectt;
                        playertot.ToString();
                        playertot += cardValue5;
                        txbxpt.Text = playertot.ToString();
                    }
                    else
                    {
                        playertot+=cardValue5;
                        txbxpt.Text = playertot.ToString();
                    }
                    
                }
                
            }
            
            
        }
    }

    public void Stay_Click(object sender, EventArgs e)
    {


        if (dealertot <= 16)
        {

        }
        else if (dealertot > playertot)
        {

        }
    }
    
    public void pCard2_Flip(object sender, EventArgs e)
    {

        picBoxP2.Image = CardPicList[randomCard2];
        picBoxD2.Image = CardPicList[randomCard7];
        dealertot += cardValue2Deal;
        txbxdt.Text = dealertot.ToString();            
        if (cardValue2 == 11)
        {
            
            popup select = new popup();
            select.Show();
            cardValue2 = popup.selectt;
            playertot += cardValue2;
            txbxpt.Text = playertot.ToString();
        }
        else
        {                
            playertot+=cardValue2;
            txbxpt.Text = playertot.ToString();
        }
    }
}

} Have no clue why it is not grabbing the value where is my error more specifically if you lookup right above that is the line of code that is not working. This is a game of blackjack and the if statements are not working all of the time or the while with the count int

Leave a Comment