一个完整身份证效验程序 根据〖中华人民共和国国家标准 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);
end;
st := '';
if IsDate(YlYear, YlMonth, Ylday) then
begin
st := YLYear + '年' + YlMonth + '月' + YLday + '日生'
end;
code := copy(identitycode, 1, 6);
st := getdetailedFromCode(code) + ':' + st;
if (StrToInt(id) mod 2 = 1) then
begin
sex := '男';
end
else
begin
sex := '女';
end;
st := st + ':' + sex + '性!' + Trim(IntToStr(e)) + '位证号!';
Result := st; end; procedure TForm1.Button1Click(Sender: TObject);
var
i, num: integer;
code, info: string;
begin
codeInfoTst := Tstringlist.Create;
CodeTst := Tstringlist.Create;
infotst := Tstringlist.Create;
try
codeInfoTst.LoadFromFile('c:\code.txt');
//分解代码地址信息
num := Codeinfotst.Count;
for i := 0 to num - 1 do
begin
code := copy(Codeinfotst[i], 1, 6);
Info := copy(Codeinfotst[i], 8, length(Codeinfotst[i]) - 7);
codetst.Add(code);
infotst.Add(info); end;
showmessage(identityInfo('530101700205379')); finally
codeTst.Free;
infotst.Free;
CodeinfoTst.Free;
end; end; end.
公民身份号码是特征组合码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);
end;
st := '';
if IsDate(YlYear, YlMonth, Ylday) then
begin
st := YLYear + '年' + YlMonth + '月' + YLday + '日生'
end;
code := copy(identitycode, 1, 6);
st := getdetailedFromCode(code) + ':' + st;
if (StrToInt(id) mod 2 = 1) then
begin
sex := '男';
end
else
begin
sex := '女';
end;
st := st + ':' + sex + '性!' + Trim(IntToStr(e)) + '位证号!';
Result := st; end; procedure TForm1.Button1Click(Sender: TObject);
var
i, num: integer;
code, info: string;
begin
codeInfoTst := Tstringlist.Create;
CodeTst := Tstringlist.Create;
infotst := Tstringlist.Create;
try
codeInfoTst.LoadFromFile('c:\code.txt');
//分解代码地址信息
num := Codeinfotst.Count;
for i := 0 to num - 1 do
begin
code := copy(Codeinfotst[i], 1, 6);
Info := copy(Codeinfotst[i], 8, length(Codeinfotst[i]) - 7);
codetst.Add(code);
infotst.Add(info); end;
showmessage(identityInfo('530101700205379')); finally
codeTst.Free;
infotst.Free;
CodeinfoTst.Free;
end; end; end.
解决方案 »
- VB6.0MSFlexGrid控件单元格颜色设置
- 将“S"转换为83的函数是那个?
- listview中添加数据后,如何使被选项自动跳到最后一行!(反蓝)
- 怎么解决这个错误?
- 100分求:怎么用vb检测web服务是否正常?
- 调查,关于大家的可用分!
- 怎么样用VB访问本地加密的ACCESS2000数据库?
- 如何取得QQ的号码列表
- 加急!求救!List中一行字符显示不下,而不想使用水平滚动条 !~
- 在MSHFlexGrid控件中显示bit型数据
- 怎样得到在rigchtext中光标的坐标?
- 使用oracle odbc driver 连接oracle 数据库后,使用中文字段显示"???"的原因?急急急!
------------------------------------------------
给朋友送手机图片、铃声,请到: oksms.sms.163.com
1 2 3 4 5
XX XXXX XXXXXX XX X 这个是没有升位以前的一个身份证号码的组成方式1 表示省 2 表示 地市 3 生日 4 顺序码 5 性别
其他的校验 都很简单或者无法校验 我在这里给大家提供一个我珍藏多年的一个数据,对籍贯进行校验
查看用户填写的身份证号码的 1 部分时候和 选择的籍贯一致,下面就是我国目前所有的 籍贯划分代码
北京 11
天津 12
河北 13
山西 14
内蒙古 15
辽宁 21
吉林 22
黑龙江 23
上海 31
江苏 32
浙江 33
安徽 34
福建 35
江西 36
山东 37
河南 41
湖北 42
湖南 43
广东 44
广西 45
海南 46
重庆 50
四川 51
贵州 52
云南 53
西藏 54
陕西 61
甘肃 62
青海 63
宁夏 64
新疆 65
台湾 71
香港 81
澳门 82
国外 91呵呵,当然 这些信息只能给我们提供尽可能的准确的信息
[email protected]
带地区的,到区为止
这么多人好热心,我可怎么给分呢;
这个贴子先给suhu(zym)吧,回头我马上发个贴子给大家分;一个不会少
suhu(zym)给我发过来了详细的,回头一起给大家;谢谢
[email protected]