locked
Round Off Based On Textbox value RRS feed

  • Question

  • User-807418713 posted

    Hello

    One scenario

    I Have One Tetxbox for example in that textbox it showing 456.23

    In textbox2 i want to show automatically -0.23

    In textbox3 i want to show 456

    Second scenario

    I Have One Tetxbox for example in that textbox it showing 750.869

    In textbox2 i want to show automatically 0.13

    In textbox3 i want to show 751

    Thanking You

    Monday, September 9, 2019 9:42 AM

Answers

  • User-1716253493 posted
            protected void TextBox1_TextChanged(object sender, EventArgs e)
            {
                Double d = Math.Round((Double)Convert.ToDouble(TextBox1.Text), 2);
                Double d2= Math.Round(d);
                TextBox2.Text = string.Format("{0:N2}", d2 - d);
                TextBox3.Text = d2.ToString();
            }

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, September 10, 2019 2:13 AM

All replies

  • User288213138 posted

    Hi Gopi.MCA,

    In textbox2 i want to show automatically -0.23

    In textbox3 i want to show 456

    In textbox2 i want to show automatically 0.13

    In textbox3 i want to show 751

    Can you explain in detail what these four values are based on?

    Best regards,

    Sam

    Monday, September 9, 2019 10:29 AM
  • User-1716253493 posted
            protected void TextBox1_TextChanged(object sender, EventArgs e)
            {
                Double d = Math.Round((Double)Convert.ToDouble(TextBox1.Text), 2);
                Double d2= Math.Round(d);
                TextBox2.Text = string.Format("{0:N2}", d2 - d);
                TextBox3.Text = d2.ToString();
            }

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, September 10, 2019 2:13 AM
  • User-807418713 posted

    Hello

    Let us consider I Have Three Tetxbox 

    For example Textbox1 Value is 456.23

    Textbox2 i want to show  -0.23 automatically

    Textbox3 i want to show 456

    I want to show roundoff for textbox1 value in textbox3

    Hope this clear

    Tuesday, September 10, 2019 11:04 AM