Does anyone have a block of VB code to do a Mod 11 Check Digit? Thanks.
Printable View
Does anyone have a block of VB code to do a Mod 11 Check Digit? Thanks.
what exactly is a "Mod 11 Check Digit"?
This is what is used for Modified Plessey barcodes and in some old banking applications
Code:Private Sub Form_Load()
Text1.Text = "80523"
Text2.Text = Mod11(Text1.Text)
End Sub
Function Mod11(str As String) As Integer
Dim tmp As Integer
Dim x As Integer
Dim FromTwoToSeven As Integer
tmp = 0
FromTwoToSeven = 2
For x = Len(str) To 1 Step -1
tmp = tmp + (CInt(Mid(str, x, 1)) * FromTwoToSeven)
FromTwoToSeven = FromTwoToSeven + 1
If FromTwoToSeven > 7 Then
FromTwoToSeven = 2
End If
Next
tmp = tmp Mod 11
Mod11 = 11 - tmp
End Function
never mind:) , found out myself.
Jim, from what I found out, there seems to be some kind of arbitary "Weightage" and "Remainder" tables, to be used.
Is that compulsory? If it is, how does your MOD11() deal with it?
The weight thing is completely standard, and also kinda arbitrary.
You work from right to left, and multiply the weight value times
the value of the digit. You add one to the weight value after each caculation. The weight cycles from 2- 7.
ie.,
The variable FromTwoToSeven cycles 2,3,4,5,6,7,2,3,4,5,6,7.....
But. It is always the same for Mod 11 checksums. There is no other way. At least that I know about.
This is ancient stuff. I did barcodes for grocery shelves using this algorithm :rolleyes: years ago.
I tried both. I picked the tables and the example from http://www.ftpconsulting.com/checkdigit.htm .Quote:
It is always the same for Mod 11 checksums
Yours returned "7" for "32174215", whereas the example given above results in "4"
:confused: