具体方法为:(1)若身份证号为15位,则根据第15位数字来判断,若为偶数则性别“女”,否则为“男”;(2)若身份证号为18位,则根据第17位数字来判断,若为偶数时则性别为“女”,否则为“男”。
图1
Dim x As String, n As Integer, s As String
x = Text1.Text
n = Len(x)
If n = 15 Then
s = Mid(, Len(x), 1)
If Val(s) Mod 2 = 0 Then
Text2.Text = "女"
Else
Text2.Text = "男"
End If
Else
s=Mid(x, 17, 1)
If Then
Text2.Text = "男"
Else
Text2.Text = "女"
End If
End If