Matthew的Blog

  IT博客 :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理 ::

 

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; 
posted on 2006-04-29 12:39 matthew 阅读(432) 评论(0)  编辑 收藏 引用 所属分类: Delphi编程
只有注册用户登录后才能发表评论。