Function: Upgrade the ID card number of 15 to 18 characters (according to GB 11643-1999)
Parameter: original number (15 digits)
Return Value: the 18-digit number after the upgrade.
Usage: = idcode (A1) (assuming that A1 contains the original 15-digit number)
About the verification code of the last digit of the ID card numberAlgorithmAs follows:
China's current use of citizens' ID card numbers follows two national standards: [GB 11643-1989] and [GB 11643-1999 〗.
[GB 11643-1989] indicates a 15-digit ID card number, which is arranged from left to right in the order of six-digit address codes and six-digit birth date codes, the three-digit sequence code, wherein the birthdate Code does not contain the number of centuries.
[GB 11643-1999] indicates the 18-digit ID card number. A citizenship number is a combination of features and consists of a 17-digit digital ontology code and a digital verification code. The six-digit address code, eight-digit birth date code, three-digit sequence code, and one-digit verification code are arranged from left to right.
the address code indicates the administrative area of the county (city, flag, district) where the resident account of the encoding object is located. Code .
the birthdate code indicates the year, month, and day of the encoded object. The year is represented by four digits, and there is no separator between the year, month, and day.
the sequence number indicates the sequence number of persons born in the same year, month, or day within the region specified by the same address code. The odd number of the sequence code is assigned to men, and the even number is assigned to women.
the verification code is calculated based on the first 17-digit code and ISO 7064: 1983.mod 11-2.
formula:
Σ (A [I] * W [I]) mod 11 (I = 2, 3 ,..., 18) (1)
"*" indicates the multiplication number
I --- indicates the serial number of each digit of the ID card number, from right to left, and 18 at the left, the rightmost is 1.
A [I] -- indicates the number on the I-digit of the ID card number
W [I] -- indicates the weight on the I-digit W [I] = 2 ^ i-1) moD 11
formula (1) makes the result r
Based on the following table, find the verification code corresponding to R, that is, the verification code C for the ID card number.
r 0 1 2 3 4 5 6 7 8 9 10
C 1 0x9 8 7 6 5 4 3 2
from this we can see that X is 10, 10 of the Roman numerals is X, so the new standard ID card number may contain non-numeric letters X.
function idcode (scode15)
dim I, num
dim Code
num = 0
idcode = left (scode15, 6) + "19" + right (scode15, 9)
'calculate the checkpoint
for I = 18 to 2 step-1
num = num + (2 ^ (I-1) mod 11) * (mid (idcode, 19-I, 1 ))
next
num = num mod 11
select case num
case 0
code = "1"
case 1
code = "0"
case 2
code = "X"
case else
code = trim (CSTR (12-num ))
end select
idcode = idcode + Code
end function