Skip to main content

Search

Search

Weighted MOD 23 Check Digit

Comments

1 comment

  • Avatar
    Peter Thane

    This would need modifying for your application this routine is a Mod23 check digit for a nine digit code (ie the Named Data Source "code") and includes both a custom check digit Array and a specific setting of weighting for each of the characters so hopefully this may help a bit:

     

    Dim CD
    CD = Array("B","W","D","F","G","K","Q","V","Y","X","A","S","T","N","J","H","R","P","L","C","Z","M","E")

    Value = Format.NamedSubStrings("code").Value

    Value1=Left(Value,1)
    Value1=Value1* 22

    Value2=Left(Value,2)
    Value2=Right(Value2,1)
    Value2=Value2*21

    Value3=Left(Value,3)
    Value3=Right(Value3,1)
    Value3=Value3*20

    Value4=Left(Value,4)
    Value4=Right(Value4,1)
    Value4=Value4*19

    Value5=Left(Value,5)
    Value5=Right(Value5,1)
    Value5=Value5*18

    Value6=Left(Value,6)
    Value6=Right(Value6,1)
    Value6=Value6*17

    Value7=Left(Value,7)
    Value7=Right(Value7,1)
    Value7=Value7*16

    Value8=Left(Value,8)
    Value8=Right(Value8,1)
    Value8=Value8*15

    Value9=Left(Value,9)
    Value9=Right(Value9,1)
    Value9=Value9*14

    Value=Value1+Value2+Value3+Value4+Value5+Value6+Value7+Value8+Value9

    Value=Value Mod 23

    Value=22-Value

    Value= CD(Value)

    0

Please sign in to leave a comment.