Skip to main content

Search

Search

Modulus 11 Check Digit

Comments

8 comments

  • Avatar
    Peter Thane

    There are a number of Mod11 check digits in the VB functions and these are all calculated differently to one another. 

    None of those encoded as standard in BarTender will give a 4 as the check digit from what I can tell and so it looks like the formula being used to calculate this is different to these and so you will need to ascertain that formula in the existing system and then replicate that in your VB.

    Please note however that 15+2300 (ie 2315) will give a different result to 152300 so you will need to check which it should actually be calculating

    0
  • Avatar
    Gary Morrow

    Hi Peter,

     

    Thanks for getting back to me. The number the customer begins with is 152300.

     

    I can calculate the modulus 11 using the normal formula:

    The Accession No. is 152300                                                                                                                         

    0+(1*(8-1))=7                                                                  

    7+(5*(8-2))=30                                                                 

    37+(2*(8-3))=10                                                                

    47+(3*(8-4))=12                                                                

    59+(0*(8-5))=0                                                                 

    59+(0*(8-6))=0                                                                  

    59 Modulus 11 = 4                                                                                                                                    

    The Check Digit is 4.

     

    Just need to get this formula moved across to the Bartender.

    So for number: 152300

    15 correlating to "EnterDate" (dd) data source, 2300 correlating to "StartNumber" data source.

    0
  • Avatar
    Peter Thane

    Okay as mentioned above all the encoded Mod 11 check digits use a different formula to this and so you would need to used something like this where the "thecode" is the name I have given to the string containing the rest of the date, ie the 152300 in this instance.

     

    Value = Format.NamedSubStrings("thecode").Value
    Value1= Mid(Value,1,1)
    Value2 = Mid(Value,2,1)
    Value3 = Mid(Value,3,1)
    Value4 = Mid(Value,4,1)
    Value5 = Mid(Value,5,1)
    Value6 = Mid(Value,6,1)

    Value1 = Value1 * 7
    Value2 = Value2 * 6
    Value3 = Value3 * 5
    Value4 = Value4 * 4
    Value5 = Value5 * 3
    Value6 = Value6 * 2

    Value = Value1+Value2+Value3+Value4+Value5+Value6

    Value = Value Mod 11

     

     

    0
  • Avatar
    Gary Morrow

    Hi Peter,

     

    Thanks that worked a treat.

    Definitely living up to your title of Bartender Hero lol

    Really appreciate your help on this one.

     

    Gary

    0
  • Avatar
    Gary Morrow

    Hi Peter,

     

    Random one. I have "thecode" set on a vb script to Value=date+code

    The code part of the label is set to serialize on print however, decrementing by 1.

    The check digit is not updating with the decrementing number however, remaining the same as the original input code.

     

    Is there a way round this?

     

    Gary

    0
  • Avatar
    Peter Thane

    You will need to amend the VB type from Multi-Line to an Event Controlled Script and include the VB code in the OnSerialise section so that it runs after the number changes

    0
  • Avatar
    Jose Adam Flores Sr.

    Make sure to Serialize by Decrementing -1 your field

    I made this script very similar to Peter's but with named Variables to make it easier to follow

    Same Result.

    mValue = Format.NamedSubStrings("mDAY").Value & Format.NamedSubStrings("mSERIAL").Value 

    mD1 = Left(mValue,1)
    mD2 = Mid(mValue,2,1)
    mC1 = Mid(mValue,3,1)
    mC2 = Mid(mValue,4,1)
    mC3 = Mid(mValue,5,1)
    mC4 = Mid(mValue,6,1)

    'The Accession No. is 152300                                                                                                                         

    mPos1 = 0+(mD1*(8-1)) ' =7                                                                  

    mPos2 = mPos1+(mD2*(8-2)) '=30                                                                 

    mPos3 =mPos2+(mC1*(8-3)) '=10                                                                

    mPos4 =mPos3+(mC2*(8-4)) '=12                                                                

    mPos5 = mPos4+(mC3*(8-5))' =0                                                                 

    mPos6 = mPos5+(mC4*(8-6)) '=0                                                                  

    mMOD = mPos6 Mod 11 '59 Modulus 11 = 4                                                                                                                                    

    'The Check Digit is 4.

    Value = mMOD

    Just Followed your Example, The m (Prefix is to designate a Memory Variable)

    Setup your Decrementing field

    Regards.

     

     

     

     

    0
  • Avatar
    Gary Morrow

    Thanks Adam. Great Bartender community on this platform.

     

    kind regards,

    Gary

    0

Please sign in to leave a comment.