本文整理自网络,侵删。
//15位身份证转18位身份证
//仅供参考
Function GetIDCard(AiIDCard : String) : String;
Const
IDCardGene : Array[1..18] Of Integer = (7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2,1);
IDCardParity : Array[0..10] Of Char = ('1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2');
ValidLen = 15;
Var
sIDCard : String;
i, s : Integer;
Begin
Result := '';
s := 0;
sIDCard := Trim(AiIDCard);
If(Length(sIDCard)=ValidLen)Then
Begin
Insert('19', sIDCard, 7);
For i := 1 To ValidLen+2 Do
Begin
s := s + StrToInt(sIDCard[i]) * IDCardGene[i];
End;
Result := sIDCard + IDCardParity[(s Mod 11)]
End;
End;
相关阅读 >>
Delphi中sendmessage给一个edit控件发送wm_settext消息
Delphi “invalid floating point operation.”错误的解决方法
Delphi ansicontainstext 是否包含子串
Delphi winapi: writeprivateprofilestring、getprivateprofilestring - 简单读写 ini 文件
更多相关阅读请进入《Delphi》频道 >>