以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  身份证提取性别  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=118957)

--  作者:chk
--  发布时间:2018/5/15 9:17:00
--  身份证提取性别

ReadSex(Value)

Value:身份证号码

例如:

Dim Identify As String = "410110197109172433"
Dim
Sex As String = ReadSex(Identify)
Output.Show(Sex)

上述代码的输出结果是“男”。


请问下这上面的身份证号码提取性别的方法,怎么操作?


--  作者:有点甜
--  发布时间:2018/5/15 9:19:00
--  

DataColChanged事件

 

If e.DataCol.Name = "身份证号码" Then
    Dim dr As DataRow = e.DataRow
    If dr.IsNull("身份证号码") Then
        dr("出生年月") = Nothing
        dr("年龄") = Nothing
        dr("性别") = Nothing
    Else
        If ValidPIN(dr("身份证号码")) = False Then
            msgbox("身份证输入不正确")
        Else
            dr("出生年月") = ReadBirthday(dr("身份证号码"))
            dr("性别") = ReadSex(dr("身份证号码"))
            Dim t As TimeSpan = today - CDate(dr("出生年月"))
            dr("年龄") = Math.Round(t.TotalDays / 365.2422,2)
        End If
    End If
End If