几个常用的身份证相关函数
Public Function SfzToXb(身份证号 As String) As String
Dim i As Integer
If Len(身份证号) = 15 And IsNumeric(Right(身份证号, 1)) Then
i = CInt(Right(身份证号, 1))
If i Mod 2 = 0 Then SfzToXb = "女" Else SfzToXb = "男"
End If
If Len(身份证号) = 18 And IsNumeric(mID(身份证号, 17, 1)) Then
i = CInt(mID(身份证号, 17, 1))
If i Mod 2 = 0 Then SfzToXb = "女" Else SfzToXb = "男"
End If
End Function
Public Function SfzToRq(身份证号 As String) As Date
Dim strRq As String
If Len(身份证号) = 15 Then
strRq = mID(身份证号, 9, 2) & "/" & mID(身份证号, 11, 2) & "/" & "19" & mID(身份证号, 7, 2)
If IsDate(strRq) Then SfzToRq = CDate(strRq)
End If
If Len(身份证号) = 18 Then
strRq = mID(身份证号, 11, 2) & "/" & mID(身份证号, 13, 2) & "/" & mID(身份证号, 7, 4)
If IsDate(strRq) Then SfzToRq = CDate(strRq)
End If
End Function
'长身份证到短身份证
Public Function LSfzToS(Sfz As String) As String
LSfzToS = Left(Sfz, 6) & mID(Sfz, 9, 9)
End Function
(责任编辑:admin)
下一篇:利用存储过程向SQL Server 2000 的表中写入大二进制文件