Search code examples
c#dice

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

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

    For example:

    label1.Text = product.BuyingPrice.ToString();