Function
In the case of both old and new ID cards, it is best to save the 18-bit after the upgrade to the database, and the following function converts the 15-bit data entered by the user to 18 bits.
Function idcode15to18 (SCode15 As String) as String
' * Function: 15 of the ID number to 18 (according to GB 11643-1999)
' * Parameter: Original number
' * return: 18-digit number after the lift
Dim I as Integer
Dim Num as Integer
Dim Code as String
num = 0
Idcode15to18 = Left (SCODE15, 6) + "-" + Right (SCODE15, 9)
' Compute the check digit
For i = 2 Step-1
num = num + (2 ^ (i-1) Mod) * (Mid (Idcode15to18, 19-i, 1))
Next I
num = num Mod 11
Select Case num
Case 0
Code = "1"
Case 1
Code = "0"
Case 2
Code = "X"
Case Else
Code = Trim (STR (12-num))
End Select
idcode15to18 = idcode15to18 + code
End Function
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.