Click here to Skip to main content
15,892,746 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I have a web form that has two textboxes on it. Textbox1 has data that is populated from the database and textbox2 is the new entry for data. When the user enters the web form textbox1 will have a number like 4000 in it. The user enters 3000 in textbox2. Textbox2 also has a Textbox Text change on it to do calculations. What I want to do is to do a calculation if the number is greater than what is in textbox1 and not to do a calculation if it is less than the number in textbox1. Can this be done?

Here is the calculation code:
C#
int o = Convert.ToInt32(TextBoxLYTCNC.Text.Replace(",", ""));
                    int p = Convert.ToInt32(TextBoxTCNC.Text.Replace(",", ""));
                    TextBoxFTE40.Text = Convert.ToString(Math.Round((Math.Abs(p - o) * 100.0 / ((o)))));
                    TextBoxFTE40.Text = Math.Round(Convert.ToDouble(TextBoxFTE40.Text), 2).ToString();
Posted

1 solution

I got this solved myself. It was fun to test out to see if I was right or wrong. Or did I have to go into another way of doing it.

C#
protected void TextBox3_TextChanged(object sender, EventArgs e)
        {
            int iTextBox2 = Convert.ToInt32(TextBox2.Text);
            int iTextBox3 = Convert.ToInt32(TextBox3.Text);

            if (iTextBox3 > iTextBox2)
            {

                int a = Convert.ToInt32(TextBox2.Text);
                int b = Convert.ToInt32(TextBox3.Text);
                TextBox4.Text = Convert.ToString(Math.Round((Math.Abs(b - a)) * 100.0 / ((a))));
            }

            else if (iTextBox3 < iTextBox2)
            {
            }
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900