|
这是别人写的可参考一下
Private Sub 职工ID_AfterUpdate()
On Error GoTo Err_职工ID_Click
If Len(职工ID) = 15 Then
xbstr = Right(Trim(职工ID), 1)
出生日期.Value = Mid(职工ID, 7, 2) & "-" & Mid(职工ID, 9, 2) & "-" & Mid(职工ID, 11, 2)
Else
If Len(职工ID) = 18 Then
xbstr = Mid(职工ID, 17, 1)
出生日期.Value = Mid(职工ID, 7, 4) & "-" & Mid(职工ID, 11, 2) & "-" & Mid(职工ID, 13, 2)
Else
MsgBox "身份证数位错误,请检查。", 64, "提醒"
职工ID.SetFocus
Exit Sub
End If
End If
result = xbstr Mod 2
If result = 0 Then
性别.Value = "女"
Else
性别.Value = "男"
End If
Exit_职工ID_Click:
Exit Sub
Err_职工ID_Click:
MsgBox "不能识别的身份证!", 64, "提醒"
Resume Exit_职工ID_Click
End Sub
|
|