Copying and Pasting cs Code

In cs, like in almost any computer programming language, reading data from a file can be tricky. You add extra lines of code to tell the computer what to do. Sometimes you can copy and paste these lines from other peoples’ code.

For example, you can follow the pattern in this listing:

   public void Button1_Click(System.Object sender, System.EventArgs e)
   {
    int a = default(int);
    decimal b = new decimal();

    if (Information.IsNumeric(TextBox3.Text))
    {
     if (int.Parse(TextBox3.Text) <= 20 )
     {
      a = (int) ((double.Parse(TextBox3.Text) * 100) / 20);
      TextBox4.Text = a.ToString();
      b = (decimal) (a * 0.1);
      TextBox5.Text = b.ToString();
     }
     else
     {
      MessageBox.Show("Please Enter value equal to 20 and below!");
     }
    }
    if (Information.IsNumeric(TextBox6.Text))
    {

     if (int.Parse(TextBox6.Text) <= 50 )
     {
      int c = default(int);
      decimal d = new decimal();
      c = (int) ((double.Parse(TextBox6.Text) * 100) / 50);
      TextBox7.Text = c.ToString();
      d = (decimal) (c * 0.1);
      TextBox8.Text = d.ToString();

     }
     else
     {
      MessageBox.Show("Please Enter value equal to 50 and below!");


     }
    }

    if (Information.IsNumeric(TextBox9.Text))
    {
     if (int.Parse(TextBox9.Text) <= 50 )
     {
      int g = default(int);
      decimal f = new decimal();
      g = (int) ((double.Parse(TextBox9.Text) * 100) / 50);
      TextBox10.Text = g.ToString();
      f = (decimal) (g * 0.2);
      TextBox11.Text = f.ToString();

     }
     else
     {
      MessageBox.Show("Please Enter value equal to 50 and below!");


     }
    }
    if (Information.IsNumeric(TextBox12.Text))
    {
     if (int.Parse(TextBox12.Text) <= 100 )
     {
      int g = default(int);
      decimal f = new decimal();
      g = (int) ((double.Parse(TextBox12.Text) * 100) / 100);
      TextBox13.Text = g.ToString();
      f = (decimal) (g * 0.3);
      TextBox14.Text = f.ToString();

     }
     else
     {
      MessageBox.Show("Please Enter value equal to 100 and below!");


     }
    }

    if (Information.IsNumeric(TextBox15.Text))
    {
     if (int.Parse(TextBox15.Text) <= 100 )
     {
      int j = default(int);
      decimal f1 = new decimal();
      j = (int) ((double.Parse(TextBox15.Text) * 100) / 100);
      TextBox16.Text = j.ToString();
      f1 = (decimal) (j * 0.3);
      TextBox17.Text = f1.ToString();

     }
     else
     {
      MessageBox.Show("Please Enter value equal to 100 and below!");


     }
    }

    decimal adal = new decimal();
    adal = (decimal) (Conversion.Val(TextBox5.Text) + Conversion.Val(TextBox8.Text) + Conversion.Val(TextBox11.Text) + Conversion.Val(TextBox14.Text) + Conversion.Val(TextBox17.Text));

    TextBox18.Text = adal.ToString();

    if (Conversion.Val(TextBox18.Text) <= 74)
    {

     TextBox19.Text = "Failed";
     TextBox19.ForeColor = Color.Red;
    }
    else
    {
     TextBox19.Text = "Passed";
     TextBox19.ForeColor = Color.Black;


    }


   }