要执行计算还是不执行计算 [英] To do Calculation or Not to do Calculation

查看:73
本文介绍了要执行计算还是不执行计算的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个网页表单,上面有两个文本框。 Textbox1具有从数据库填充的数据,textbox2是数据的新条目。当用户输入网络表单时,textbox1将包含一个类似4000的数字。用户在textbox2中输入3000。 Textbox2还对其进行了文本框文本更改以进行计算。我想要做的是如果数字大于textbox1中的数字进行计算,如果它小于textbox1中的数字则不进行计算。可以这样做吗?



这是计算代码:

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:

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();

推荐答案

我自己解决了这个问题。测试看我是对还是错是很有趣的。或者我是否必须采取另一种方式。



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.

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)
            {
            }


这篇关于要执行计算还是不执行计算的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆