我想要输出平衡假 [英] i want the output balance leave

查看:49
本文介绍了我想要输出平衡假的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在应用程序中具有以下字段,如下所示:

I have following fields in the application as follows:

Eligibility Leave    36   Texbox1
Availed  Leave        3   Textbox2
Balance              33   Textbox3


Textbox2中键入Availed Leave 3时,我希望输出为33(平衡).


When I type Availed Leave 3 in Textbox2, I want the output as 33 (Balance).

private void txt_availed_TextChanged(object sender, EventArgs e)
       {

       }


请发送验证码.

问候,
Rao.


Please send the code.

Regards,
Rao.

推荐答案

private void txt_availed_TextChanged(object sender, EventArgs e)         
{
            int eligibility = 0;
            int availed = 0;
            bool isValidValue = true;

            try
            {
                eligibility = int.Parse(textBox1.Text);
            }
            catch
            {
                isValidValue = false;
            }

            try
            {
                availed = int.Parse(textBox2.Text);
            }
            catch
            {
                isValidValue = false;
            }

            if (isValidValue)
            {
                textBox3.Text = (eligibility - availed).ToString();
            }
            else
            {
                textBox3.Text = "";
            }
        }


if (!string.IsNullOrEmpty(textBox1.Text) && !string.IsNullOrEmpty(textBox2.Text))
            {
                textBox3.Text = (int.Parse(textBox1.Text) - int.Parse(textBox2.Text)).ToString();
            }
            else
            {
                textBox3.Text = "";
            }


try
            {
                textBox3.Text = (int.Parse(textBox1.Text) - int.Parse(textBox2.Text)).ToString();
            }
            catch
            {
                textBox3.Text = "";
            }


这篇关于我想要输出平衡假的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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