An 18-digit ID card verification calculation function

Source: Internet
Author: User
Because I needed to perform the escalation, verification, and query of the 15-digit old ID card number, and did not find any ready-made functions, I wrote a simple process and hoped to help my friends.
This function has a single function and can only verify whether the 18th-bit number is correct or obtain the 18th-bit number. Other functions can be expanded by yourself!
<%
'Version: 1.0.1
'Author: sfply (sfply@163.com)
'Last Modified: 2004/7/17 12:03
'Src is the ID card number, which can be 15 or 18 digits. Only the verification code can be returned for 15 digits.
The value of the 'ichk parameter is true or false. It indicates whether the Src 18-digit ID card is verified, and whether the 18th-digit number is correct to determine whether the ID card is valid. The return value is true or false.
'False' indicates that the correct verification code is returned. The returned value is (1 ~ X)
Dim myIdentify
MyIdentify = "36050219781218133? "
Response. write chkIdentiyCard (myIdentify, false)
Function chkIdentiyCard (Src, iChk)
Dim myWi, myAi, mySrc (17), I, myCount
MyAi = "10X98765432"
MyWi = split ",",")
If iChk then
If len (Src) = 18 then
For I = 0 to 16
MySrc (I) = mid (Src, I + 1, 1)
MyCount = myCount + mySrc (I) * myWi (I)
Next
If mid (myAi, (mycount mod 11) + 1,1) = right (Src, 1) then
ChkIdentiyCard = true'. true indicates the valid ID card verification code.
Else
ChkIdentiyCard = false'. false indicates that the ID card verification code is invalid.
End if
Else
ChkIdentiyCard = false' returns false because it is not an 18-digit ID card.
End if
Else
If len (Src) = 15 or len (Src) = 18 then
If len (Src) = 15 then Src = mid (Src,) & "19" & mid (Src)
For I = 0 to 16
MySrc (I) = mid (Src, I + 1, 1)
MyCount = myCount + mySrc (I) * myWi (I)
Next
ChkIdentiyCard = mid (myAi, (mycount mod 11) +) 'returns the correct verification code
Else
ChkIdentiyCard = false' do not enter a 15-digit or 18-digit ID card number
End if
End if
End Function
%>
How to calculate ID card 18th is as follows:
According to the provisions on citizenship numbers in the national standard of the People's Republic of China GB 11643-1999, a citizenship number is a feature combination code consisting 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.
Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

Contact Us

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.