Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Cannot get int to be displayed in text box for dice roller app

I’m trying to get back into programming and I’m having trouble getting the final int answers into the text boxes at the end. It has been a few years since I’ve coded, so if I messed up big time, please let me know.

     {
         int dice_total;
         int dice_num;
         int diff_num;
         int succ_num = 0;
         int ones = 0;
         Boolean comp_num = false;
         string Succ;
         string Comp;

         dice_total = int.Parse(Dice.Text);
         diff_num = int.Parse(Diff.Text);
         Random random = new Random();
         dice_num = random.Next(dice_total);
         
         if (dice_num >= diff_num)
         {
             succ_num++;
         }
         else
         {
             if (dice_num == 1)
             {
                 ones++;
             }
         }

         if (ones >= succ_num)
         {
             comp_num = true;
         }
         else
         {
             comp_num = false;
         }

         Succ = succ_num.ToString();
        
         Comp = comp_num.ToString();
         
         
     }```

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

[your text box name].Text=[some int].ToString();

for example:
label1.Text = product.BuyingPrice.ToString();

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading