Function IdCheck(s As String, birthday As String, sex As String) As Boolean Dim code1, code2, i As Integer, n As Integer, temp As String code1 = Split("1 0 X 9 8 7 6 5 4 3 2") code2 = Split("7 9 10 5 8 4 2 1 6 3 7 9 10 5 8 4 2 1") s = UCase(Trim(s)) If Len(s) = 15 Then temp = Mid(s, 1, 6) & "19" & Mid(s, 7) ElseIf Len(s) = 18 Then temp = Left(s, 17) Else Exit Function End If For i = 0 To Len(temp) - 1 n = n + Mid(temp, i + 1, 1) * code2(i) Next n = n Mod 11 If Len(s) = 18 And code1(n) <> Right(s, 1) Then Exit Function IdCheck = True If Len(s) = 15 Then birthday = Format("19" & Mid(s, 7, 6), "#0000-00-00") sex = IIf(Right(s, 1) Mod 2 = 1, "男", "女") Else birthday = Format(Mid(s, 7, 8), "#0000-00-00") sex = IIf(Mid(s, 17, 1) Mod 2 = 1, "男", "女") End If End Function