本文整理自网络,侵删。
//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 winapi: messagebeep - 播放一个系统声音
Delphi让tedit控件的内容居中或右对齐,限制位数,仅允许输入数字
Delphi 如何在webservice中获取客户端的ip地址
Delphi xe5在zip文件中添加某个txt文件并写入文字
更多相关阅读请进入《Delphi》频道 >>