|
-
Jun 8th, 2002, 07:26 AM
#1
Thread Starter
Lively Member
Mod 11 Check Digit
Does anyone have a block of VB code to do a Mod 11 Check Digit? Thanks.
VB6 & VC++6 Pro (SP4), Java (Sun JDK)
-
Jun 8th, 2002, 07:50 AM
#2
Frenzied Member
what exactly is a "Mod 11 Check Digit"?
"Brothers, you asked for it."
...Francisco Domingo Carlos Andres Sebastian D'Anconia
-
Jun 8th, 2002, 07:56 AM
#3
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
-
Jun 8th, 2002, 08:09 AM
#4
Frenzied Member
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?
"Brothers, you asked for it."
...Francisco Domingo Carlos Andres Sebastian D'Anconia
-
Jun 8th, 2002, 08:20 AM
#5
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 years ago.
-
Jun 8th, 2002, 08:56 AM
#6
Frenzied Member
It is always the same for Mod 11 checksums
I tried both. I picked the tables and the example from http://www.ftpconsulting.com/checkdigit.htm .
Yours returned "7" for "32174215", whereas the example given above results in "4"
"Brothers, you asked for it."
...Francisco Domingo Carlos Andres Sebastian D'Anconia
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|