黑猫物语's Archivers

From 阿尔特密斯 on 2007-09-01 21:25:34

从身份证中获得生日,性别,民族等信息Asp类

<% Class IDCardInfo Private strAuthor ,strVersion ,StrMessage,StrIDCard Public Property Let IDCard(ByVal strVar) StrIDCard =strVar End Property Public Property Get Version Version = strVersion End Property Public Property Get Author Author = strAuthor End Property Public Property Get DataList DataList = strDataList End Property Private Sub Class_Initialize() strAuthor = "林其浓--http://www.youthbar.com" strVersion = "1.0" strMessage="该类功能:从省份证号码中获得生日,性别,籍贯等信息,欢迎测试使用!<br>联系制作者:<a href='mailto:master@youthbar.com'>林其浓</a> @ <a href='http://www.youthbar.com'>www.youthbar.com</a>.<br>" End Sub Private Sub Class_Terminate() 'Response.Write "<br>myClass结束了<br>" End Sub Public Property Get Message Message=StrMessage End Property Public Property Get Error Error=CardErr() End Property Function IDCheck(e) IDCheck = "" arrVerifyCode = Split("1,0,x,9,8,7,6,5,4,3,2", ",") Wi = Split("7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2", ",") Checker = Split("1,9,8,7,6,5,4,3,2,1,1", ",") If Len(e) < 15 Or Len(e) = 16 Or Len(e) = 17 Or Len(e) > 18 Then IDCheck= "身份证号共有 15 码或18位" Exit Function End If Dim Ai If Len(e) = 18 Then Ai = Mid(e, 1, 17) ElseIf Len(e) = 15 Then Ai = e Ai = Left(Ai, 6) & "19" & Mid(Ai, 7, 9) End If If Not IsNumeric(Ai) Then IDCheck= "身份证除最后一位外,必须为数字!" IDCheck = False Exit Function End If Dim strYear, strMonth, strDaym,BirthDay strYear = CInt(Mid(Ai, 7, 4)) strMonth = CInt(Mid(Ai, 11, 2)) strDay = CInt(Mid(Ai, 13, 2)) BirthDay = Trim(strYear) + "-" + Trim(strMonth) + "-" + Trim(strDay) If IsDate(BirthDay) Then If DateDiff("yyyy",Now,BirthDay)<-140 or cdate(BirthDay)>date() Then IDCheck= "身份证输入错误!" IDCheck = False Exit Function End If If strMonth > 12 Or strDay > 31 Then IDCheck = False IDCheck= "身份证输入错误!" Exit Function End If Else IDCheck= "身份证输入错误!" Exit Function End If Dim i, TotalmulAiWi For i = 0 To 16 TotalmulAiWi = TotalmulAiWi + CInt(Mid(Ai, i + 1, 1)) * Wi(i) Next Dim modValue modValue = TotalmulAiWi Mod 11 Dim strVerifyCode strVerifyCode = arrVerifyCode(modValue) Ai = Ai & strVerifyCode IDCheck =True' Ai If Len(e) = 18 And e <> Ai Then IDCheck= "身份证号码输入错误!" Exit Function End If End Function Function IDCheckedStr(e) IDCheckedStr= "" arrVerifyCode = Split("1,0,x,9,8,7,6,5,4,3,2", ",") Wi = Split("7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2", ",") Checker = Split("1,9,8,7,6,5,4,3,2,1,1", ",") If Len(e) < 15 Or Len(e) = 16 Or Len(e) = 17 Or Len(e) > 18 Then IDCheckedStr= "身份证号共有 15 码或18位" Exit Function End If Dim Ai If Len(e) = 18 Then Ai = Mid(e, 1, 17) ElseIf Len(e) = 15 Then Ai = e Ai = Left(Ai, 6) & "19" & Mid(Ai, 7, 9) End If If Not IsNumeric(Ai) Then IDCheckedStr= "身份证除最后一位外,必须为数字!" IDCheckedStr = False Exit Function End If Dim strYear, strMonth, strDay,BirthDay strYear = CInt(Mid(Ai, 7, 4)) strMonth = CInt(Mid(Ai, 11, 2)) strDay = CInt(Mid(Ai, 13, 2)) BirthDay = Trim(strYear) + "-" + Trim(strMonth) + "-" + Trim(strDay) If IsDate(BirthDay) Then If DateDiff("yyyy",Now,BirthDay)<-140 or cdate(BirthDay)>date() Then IDCheckedStr= "身份证输入错误!" IDCheckedStr = False Exit Function End If If strMonth > 12 Or strDay > 31 Then IDCheckedStr = False IDCheckedStr= "身份证输入错误!" Exit Function End If Else IDCheckedStr= "身份证输入错误!" Exit Function End If Dim i, TotalmulAiWi For i = 0 To 16 TotalmulAiWi = TotalmulAiWi + CInt(Mid(Ai, i + 1, 1)) * Wi(i) Next Dim modValue modValue = TotalmulAiWi Mod 11 Dim strVerifyCode strVerifyCode = arrVerifyCode(modValue) Ai = Ai & strVerifyCode IDCheckedStr = Ai If Len(e) = 18 And e <> Ai Then IDCheckedStr= "身份证号码输入错误!" Exit Function End If End Function Private Function CardErr() CardErr=IDCheck(StrIDCard) End Function Public Function CardLen() if CardErr()=True then CardLen=len(IDCheckedStr(StrIDCard)) end if End Function Public Function BirthDay() Dim strYear, strMonth, strDay,Ai Ai=IDCheckedStr(StrIDCard) if CardErr()=true then strYear = CInt(Mid(Ai, 7, 4)) strMonth = CInt(Mid(Ai, 11, 2)) strDay = CInt(Mid(Ai, 13, 2)) BirthDay = Trim(strYear) + "-" + Trim(strMonth) + "-" + Trim(strDay) else BirthDay="" end if End Function Public Function Sex() if CardErr()=true then sex=MID(IDCheckedStr(StrIDCard),17,1) End if End FunctionEnd Classdim NewClassSet NewClass = New IDCardInfoNewClass.IDCard="330325821217511" %> <pre>作者: <%= NewClass.Author %>版本: <%= NewClass.Version %>类说明:<%= NewClass.Message %> 数据列表: <%' NewClass.DataList %>错误: <%= NewClass.error %>长度: <% = NewClass.CardLen%>生日:<%= NewClass.BirthDay() %>性别:<%= NewClass.Sex() %></pre><pre>新身份证号:XX|XX|XX|XXXX|XX|XX|XXX|X省|市|区|出生年|月|日|编号|效验码老身份证号:XX|XX|XX|XX|XX|XX|XXX省|市|区|出生年月|日|编号收集省市区的编码建立一张基础数据表,通过该表查询。北京 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

查看完整版本: 从身份证中获得生日,性别,民族等信息Asp类

From cigarel on 2007-09-02 19:22:01

[sweat] 同学...

Tags:


©黑猫物语 51La