当前位置: 首页 > 图文教程 > 网络编程 > ASP > 将身份证从15位升级为18位的函数

ASP
ASP简单入门教程(2):ASP环境配置
ASP简单入门教程(3):ASP语法
ASP简单入门教程(4):ASP变量
ASP简单入门教程(5):ASP子程序
HTTP 500 - 内部服务器错误(补充内容)
ASP教程:IIS中配置多站点
ASP实例教程:Content Rotator (ASP 3.0)
ASP实例教程:Content Linking组件
ASP实例教程:Browser Capabilities组件
ASP实例教程:AdRotator组件
ASP实例教程:Dictionary对象
ASP实例教程:File对象
ASP实例教程:Drive对象
ASP实例教程:TextStream对象
关于学习ASP的20个测试题目
ASP实例教程:Server对象
ASP实例教程:Session对象
ASP实例教程:用户信息和服务器
asp教程:解决IIS安装问题
ASP网站数据库被挂木马的处理办法

ASP 中的 将身份证从15位升级为18位的函数


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 88 ::
收藏到网摘: n/a

 

    '将身份证从15位升级为18位的函数

    Function GetNewIDCard(ByVal IDCard As String) As String
        Dim i, S As Integer
        Dim Wi() As String = Split("7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2,1", ",")
        Dim Wf() As String = Split("1,0,X,9,8,7,6,5,4,3,2", ",")
        If Mid(IDCard, 7, 2) >= Mid(Now.AddYears(-14).Year, 3, 2) Then
            IDCard = Mid(IDCard, 1, 6) & "18" & Mid(IDCard, 7, 9)
        Else
            IDCard = Mid(IDCard, 1, 6) & "19" & Mid(IDCard, 7, 9)
        End If
        For i = 0 To 16
            S += Wi(i) * Mid(IDCard, i + 1, 1)
        Next
        Return IDCard & Wf(S Mod 11)
    End Function