Obtain the desired information through the ID card number

Source: Internet
Author: User
I recently read an article about how to obtain necessary information through the ID card number. I think that when I was using the MS system, I usually need to enter the ID card number, gender, and date of birth, these inputs can be obtained only through the ID card, which should be repeated input. In addition, the consistency between the gender and birth date and the ID card can be verified to avoid input errors, the code below is a self-written code that obtains the necessary information through a 15-and 18-digit ID card. It is also fun.

Code
Option explicit

'Id card type
'Get gender and Date of Birth through ID card number

Private ID _ as string
Private const idcard_length_description as string = "ID card number must be 15 or 18 characters"

'Id card No.
Public property get ID () as string
Assert Len (ID _) = 15 or Len (ID _) = 18, me, "ID", idcard_length_description
Id = ID _
End Property

Public property let ID (byval Sid as string)
Assert Len (SID) = 15 or Len (SID) = 18, me, "ID", idcard_length_description
ID _ = Sid
End Property

'Id No. Length
Public property get idlength () as integer
Idlength = Len (ID _)
End Property

'Gender
Public property get sex () as string
Dim stemp as string

Assert idlength = 15 or idlength = 18, me, "sex", idcard_length_description

Select case idlength
Case 15
Stemp = mid (ID _, 13, 3)
Case 18
Stemp = mid (ID _, 3, 15)
End select

If CINT (stemp) mod 2 = 0 then
Sex = "female"
Else
Sex = "male"
End if

End Property

'Birthdate
Public property get birthday () as string
Dim stemp as string

Assert idlength = 15 or idlength = 18, me, "Birthday", idcard_length_description

Select case idlength
Case 15
Stemp = mid (ID _, 7, 6)
Stemp = "19" & stemp
Case 18
Stemp = mid (ID _, 7, 8)
End select

Birthday = mid (stemp, 1, 4) & "/" & Mid (stemp, 5, 2) & "/" & Mid (stemp, 7, 2)

End Property

 

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.