Personal code checker

Here is software, source code and excel worksheet to check citizens personal identification code used in Lithuania. Checking the code is mandatory when filling various legal documents.

Here is the checker as independent MS Visual Basic program. As I have only old version of the basic, the software is not Unicode compatible. Download ID checker software.

The program may require MS Visual Basic runtime. You can download it at MS web site.

The algorithm is very same. It can be ported to any other programming language:

Backslash “\” means the you don’t need to break line.

Private Function chksum(ak)
Dim c, c1
c = Val(Mid$(ak, 1, 1)) + Val(Mid$(ak, 2, 1)) * 2 + 
\ Val(Mid$(ak, 3, 1)) * 3 + Val(Mid$(ak, 4, 1)) * 4 + 
\ Val(Mid$(ak, 5, 1)) * 5 + Val(Mid$(ak, 6, 1)) * 6 +
\ Val(Mid$(ak, 7, 1)) * 7 + Val(Mid$(ak, 8, 1)) * 8 + 
\ Val(Mid$(ak, 9, 1)) * 9 + Val(Mid$(ak, 10, 1))
c = c Mod 11
c1 = Val(Mid$(ak, 1, 1)) * 3 + Val(Mid$(ak, 2, 1)) * 4 +
\ Val(Mid$(ak, 3, 1)) * 5 + Val(Mid$(ak, 4, 1)) * 6 +
\ Val(Mid$(ak, 5, 1)) * 7 + Val(Mid$(ak, 6, 1)) * 8 +
\ Val(Mid$(ak, 7, 1)) * 9 + Val(Mid$(ak, 8, 1)) * 1 + 
Val(Mid$(ak, 9, 1)) * 2 + Val(Mid$(ak, 10, 1)) * 3
c1 = c1 Mod 11
If c <> 10 Then
    chksum = c
ElseIf c1 <> 10 Then
    chksum = c1
Else
    chksum = 0
End If
End Function

Private Function ak(s)
Dim i
i = chksum(s)
If Mid$(s, 11, 1) = i Then
    ak = True
Else
    ak = False
End If
End Function

The source above as text file.
And here is the same software in MS Excel sheet. Don’t forget to adjust security setting to allow running macros and visual basic commands.

About Administrator

I am owner of this site.
This entry was posted in Anything. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *