如何在按钮中调用布尔方法 [英] how to call boolean method in button

查看:88
本文介绍了如何在按钮中调用布尔方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

public Boolean TFN()
    {
        Boolean tfn_status = false;
        if (txtTaxFileNumber.Text != null)
        {
            int sum = 0;
           
            string txtnumber = txtTaxFileNumber.Text;
            char[] nums = txtnumber.ToCharArray();
            int[] WEIGHT = new Int32[8] { 10, 7, 8, 4, 6, 3, 5, 1 };

            int val = 0;
            for (int i = 0; i < nums.Length; i++)
            {
                val += ((int)(nums[i])) * WEIGHT[i];
            }
            int remainder = val % 11;



            if (remainder == 0)
            {
                tfn_status = true;

            }

            else
            {
                tfn_status = false;
               
            }
           
        }
        return tfn_status;
    }

推荐答案

您不能立即将此函数作为事件调用,因为它不适合该格式...如果那样的话,这就是您要尝试做的.但是,如果您愿意,可以从实际事件中调用它.
You can''t call this function immediately as an event, because it doesn''t fit the format... If that''s what you''re trying to do. But, if you want, you could call it from the actual event.


我没有收到您的问题.

我想您正在寻找这个.

在button_click事件中

I am not getting your question.

I think you are looking for this.

in button_click event

button1_click(object sender,eventArgs e)
{
   Boolean blAns = TFN();
   if(blAns)
   {
      //to do for Yes
   }
   else
   {
      //to do for No
   }
}


这篇关于如何在按钮中调用布尔方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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