用BCB编写身份证号识别程序

王朝other·作者佚名  2006-01-08
宽屏版  字体: |||超大  

//按钮被单击的事件,建立一个输入框EDIT1和一个标签LABEL1以及一个按钮BUTTON1

void __fastcall TForm1::Button1Click(TObject *Sender)

{

AnsiString a,b,c,d,f;

AnsiString EditText = Edit1->Text;

int e;

e=StrLen(EditText.c_str());

if (e==18)

{

Edit1->SelStart=6;

Edit1->SelLength=4;

a=Edit1->SelText;

Edit1->SelStart=10;

Edit1->SelLength=2;

b=Edit1->SelText;

Edit1->SelStart=12;

Edit1->SelLength=2;

c=Edit1->SelText;

Edit1->SelStart=16;

Edit1->SelLength=1;

d=Edit1->SelText;

if((StrToInt(d)%2)==1)

{

f="男";

}

else

{

f="女";

}

Label1->Caption="您是"+a+"年"+b+"月"+c+"日生人!"+f+"性!"+Trim(IntToStr(e))+"位证号!";

return;

}

if (e==15)

{

Edit1->SelStart=6;

Edit1->SelLength=2;

a="19"+Edit1->SelText;

Edit1->SelStart=8;

Edit1->SelLength=2;

b=Edit1->SelText;

Edit1->SelStart=10;

Edit1->SelLength=2;

c=Edit1->SelText;

Edit1->SelStart=14;

Edit1->SelLength=1;

d=Edit1->SelText;

if((StrToInt(d)%2)==1)

{

f="男";

}

else

{

f="女";

}

Label1->Caption="您是"+a+"年"+b+"月"+c+"日生人!"+f+"性!"+Trim(IntToStr(e))+"位证号!";

return;

}

ShowMessage("输入的身份证号不正确!");

}

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
© 2005- 王朝网络 版权所有