C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Code Snippets » Validations »

Validation in WinForms for PAN number


Posted Date: 17 Apr 2009    Resource Type: Code Snippets    Category: Validations
Author: Deepika HaridasMember Level: Diamond    
Rating: 1 out of 5Points: 15



PAN number validation
PAN number format which is having total 10 characters.
1st 5 character are letter, next 4 digits and last one is either letter or digit


private void textBox1_KeyPress(object sender, KeyPressEventArgs e)

{
int sLength = textBox1.SelectionStart;

switch (sLength)
{
case 0:

case 1:

case 2:

case 3:

case 4:

if (char.IsLetter(e.KeyChar) || Char.IsControl(e.KeyChar))
{
e.Handled = false;
}
else
{
e.Handled = true;
}
break;

case 5:

case 6:

case 7:

case 8:
if (char.IsNumber(e.KeyChar) || Char.IsControl(e.KeyChar))
{
e.Handled = false;
}
else
{
e.Handled = true;
}
break;
case 9:
if (char.IsLetter(e.KeyChar) || Char.IsControl(e.KeyChar))
{
e.Handled = false;
}
else
{
if (Char.IsControl(e.KeyChar))
{
e.Handled = false;
}

else
{
e.Handled = true;
}
}
break;
default:
if (Char.IsControl(e.KeyChar))
{
e.Handled = false;
}

else
{
e.Handled = true;
}
break;
}
}



Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
Winforms  .  Switch  .  PAN  .  Number  .  KeyChar  .  Char  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Password Validation
Previous Resource: Assessment Year validation in WinForms
Return to Discussion Resource Index
Post New Resource
Category: Validations


Post resources and earn money!
 
More Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use