Skip to main content

Search

Search

How To Create A Check Digit Using Vb Script

Comments

7 comments

  • Avatar
    Ian Cummings
    Moderator

    What barcode symbology are you supposed to be using?

     

    If not directly supported in the symbology options then you would set about creating a check digit in the following manner:

     

    1. Create the barcode object with the principal data source.  Give this data source a name, which we can then reference from a VB script.

     

    2. Create a second data source in the same barcode object using a VB script data type.  Edit the VB script.

     

    3. To make a calculation on the main data source of the barcode we make reference to the data source previously named.  For example if we named the data source "btBarcode" then the reference in the VB script would look like this.

     

    Format.NamedSubStrings("btBarcode").Value

     

    4. In a very simple fashion a MOD32 calculation could be made like the following.  However, such barcode check digits are calculated normally in a more complex "weighted" manner.  You'll need to get details on how your specific MOD32 should be calculated.

     

    value = Format.NamedSubStrings("btBarcode").Value Mod 32

    0
  • Avatar
    Legacy Poster

    First of all thank you for the help,

    I'm suppost to multiply every digit in the barcode by a weighting number, which is equal to it’s position in the barcode string starting with 12. Sum the products modulo 32.


     

     

    For example : 9AE2222BFE2A barcode will be break down like this


     

    (9*12)+(10*11)+(14*10)+(2*9)+(2*8)+(2*7)+(2*6)+(11*5)+(15*4)+(14*3)+(2*2)+

    (10*1) = 589


    (589) Mod 32 = 13

    The check digit in this case is 13, im suppost to use letters as well, and letters are given a diiferen value


     

    for example A=10, B=11, C=12, D=13.....

    0
  • Avatar
    Ian Cummings
    Moderator

    Sorry for the delay -- I was caught up in other things -- the below VB script should do the trick:

     

    varTotal = 0
    varMultiplier = 12
    
    For varCount = 1 To 12
    	varTotal = varTotal + ((Int("&H" & Mid(Format.NamedSubStrings("btBarcode").Value, varCount, 1))) * varMultiplier)
    	varMultiplier = varMultiplier -1
    Next
    
    value = varTotal Mod 32
    
    0
  • Avatar
    Legacy Poster

    Hi, I have a similar request for a VB Script but I need it for MOD-11 with 1,3,7 Weighting.  I have not got the actual formula to work it out but I might be able to get it with some effort.

     

    Here is some sample data with the check digit.

     

     

    04508760 check digit is 0

    04508784 check digit is 4

    04508801 check digit is 1

     

    thanks

     

    Paul

    0
  • Avatar
    Legacy Poster

    Also, here are some 6 characters plus a check digit samples

     

    8095020 check digit is 0

    8095013 check digit is 3

    8095068 check digit is 8

    0
  • Avatar
    Hajeera Khatoon

    Dera Experts, 

    Can anyone please share vbscript to generate checkdigit for GS-128 SSCC number 

     

    Thnak you , 

    Hajeera 

    0
  • Avatar
    Ian Cummings
    Moderator

    We have a built in function for that found under the "Check Digits" folder.  The one you want is UccMod10() with the syntax of: UccMod10(String, [AppendString])

    Therefore, the string input for the function could be a literal value or reference to a value like for an object or a named data source.  There is also an optional item to prepend the input value with a true/false setting.  See below a couple of examples respectively.

    UccMod10(00123456000000001, False)

    UccMod10(Format.Objects("Barcode 1").Value, False)

    UccMod10(Format.NamedSubStrings("mySSCC").Value, True)

    *The answers a more recent question on generating a SSCC check digit.

    0

Please sign in to leave a comment.