Delphi中国  
首页 | 电脑常识 | 业界动态 | Delphi相关 | 最新源码 | 网络文摘 | 常用工具 | 专题 | 会员中心
  当前位置:首页>Delphi相关>参考资料>文章内容

一个完整身份证效验程序
来源:本站 作者:admin 发布时间:2007-05-12  
根据〖中华人民共和国国家标准 GB 11643-1999〗中有关公民身份号码的规定,
公民身份号码是特征组合码18位:由十七位数字本体码和一位数字校验码组成。排列顺序从左至右依次为:六位数字地址码,八位数字出生日期码,三位数字顺序码和一位数字校验码。
地址码表示编码对象常住户口所在县(市、旗、区)的行政区划代码。生日期码表示编码对象出生的年、月、日,其中年份用四位数字表示,年、月、日之间不用分隔符。顺序码表示同一地址码所标识的区域范围内,对同年、月、日出生的人员编定的顺序号。顺序码的奇数分给男性,偶数分给女性。
15位:六位数字地址码,六位数字出生日期码,三位数字顺序码和一位数字校验码。
var
    codeInfoTst: Tstrings; //总
    codeTst: Tstrings; //代码
    InfoTst: Tstrings; //地址信息

function identityInfo(identitycode: string): string;
//由年月日判断是否为有效日期
    function IsDate(Year, Month, Day: string): Boolean;
    var
        st: string;
    begin

        st := Year + '-' + Month + '-' + day;
        try
            StrToDate(st);
            Result := True;
        except

            Result := False;

        end;
    end;


    function getdetailedFromCode(code: string): string; //由身份证的前六位获得省份县市信息
    var
        Index: integer;
        St: string;
    begin
        index := codeTst.IndexOf(code);
        if index = -1 then
        begin
            Result := '';
            exit;
        end;
        st := infoTst[index]; //县
        code := copy(code, 1, 4) + '00';
        index := codeTst.IndexOf(code);
        if index = -1 then
        begin
            Result := st;
            exit;
        end;
        st := infoTst[index] + st; //市

        code := copy(code, 1, 2) + '0000';
        index := codeTst.IndexOf(code);
        if index = -1 then
        begin
            Result := st;
            exit;
        end;
        st := infoTst[index] + st; //省
        Result := st;



    end;

var
    YLYear, YLMonth, YlDay, id, sex, code: string;
    E: integer;
    St: string;

begin


    e := Length(identitycode);
    if (e <> 18) or (e <> 15) then result := '';
    if (e = 18) then
    begin
        YLYear := copy(identitycode, 7, 4);
        YlMonth := copy(identitycode, 11, 2);
        YLday := copy(identitycode, 13, 2);
        id := copy(identitycode, 18,1);
    end;
    if (e = 15) then
    begin
        YLYear := '19' + copy(identitycode, 7, 2);
        YlMonth := copy(identitycode, 9, 2);
        YLday := copy(identitycode, 11, 2);
        id := copy(identitycode, 15, 1);
(阅读次数:

共8页: 上一页 1 [2] [3] [4] [5] [6] [7] [8] 下一页
上一篇:Delphi IDE使用的一些主要技巧   下一篇:Delphi函数参考手册
[收藏] [推荐] [评论(0条)] [返回顶部] [打印本页] [关闭窗口]  
用户名: 新注册) 密码: 匿名评论
评论内容:(不能超过250字,需审核后才会公布,请自觉遵守互联网相关政策法规。
 §最新评论
  热点文章
·Delphi游戏开发相关网址
·Delphi7.0常用函数速查手册
·Delphi 6 程序员代码编写标准指
·公用函数
·一些界面标准规范
·Windows消息大全使用详解
·关于文件操作集锦
·Delphi中资源文件使用详解
·Delphi编译错误信息对照表
·Delphi6开发基础模拟题
·Delphi软件工程师试题
·Delphi编程代码规范
  相关文章
·Delphi IDE使用的一些主要技巧
·Delphi函数参考手册
·在Delphi程序中操作注册表
·Delphi中预想不到的代码
·Delphi6函数大全(3)
·OICQ服务器系统通讯协议
·Delphi6函数大全(2)
·Windows消息大全使用详解
·Delphi6函数大全(1)
·键值大全
·Oracle函数
·Delphi控制Excel的重要属性和方

Delphi中国
苏ICP备07008953