Results 1 to 6 of 6

Thread: Mod 11 Check Digit

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Aug 2000
    Location
    Philadelphia
    Posts
    123

    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)

  2. #2
    Frenzied Member KayJay's Avatar
    Join Date
    Jul 2001
    Location
    Chennai
    Posts
    1,849
    what exactly is a "Mod 11 Check Digit"?

    "Brothers, you asked for it."
    ...Francisco Domingo Carlos Andres Sebastian D'Anconia

  3. #3
    jim mcnamara
    Guest
    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

  4. #4
    Frenzied Member KayJay's Avatar
    Join Date
    Jul 2001
    Location
    Chennai
    Posts
    1,849
    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

  5. #5
    jim mcnamara
    Guest
    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.

  6. #6
    Frenzied Member KayJay's Avatar
    Join Date
    Jul 2001
    Location
    Chennai
    Posts
    1,849
    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
  •  



Click Here to Expand Forum to Full Width