Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
C#
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;
    }
Posted
Updated 25-Oct-11 3:59am
v2
Comments
André Kraak 25-Oct-11 10:01am    
Edited question:
Added pre tags
Abhinav S 25-Oct-11 10:04am    
Can you provide more details? This question is not clear.

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.
 
Share this answer
 
I am not getting your question.

I think you are looking for this.

in button_click event

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

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



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