# How To Create A Check Digit 追蹤

Legacy Poster

HI, Im a complete newbei when it come to Bartender, i got this issue I want a create a 13 digit hexadecimal serialize barcode and one of those digit i need to be a check digit. i look around and in the VB scripiting i found something but I dont know how to use, I have a formula in excel that calculates the number but it takes to much time to create 20 serialed numbers. AnyHelp will be helpfull.

##### 5 意見

###### Ian Cummings

Breakup the data source of your barcode into two. The first data source contains the main data of the barcode. Give this data source a name which you can then reference. In the second data source use the VB script type and use the data source name of the main barcode data as an input for your check digit calculation.

For example, if you named the first data source "btBarcode".

Then a VB script expression to calculate the check digit could look like the below, which uses a built-in functions. In this case I used the UccMod10() function.

value = UccMod10(Format.NamedSubStrings("btBarcode").Value)
###### Legacy Poster

Hi, I have also a problem with a check digit. I have a serialnumber of 18 digits (089501131595900113). The customer wants a Mod 97 check on it. The problem is that I can't find a data type that can handle such a number of digits.

The script I use is (Works fine with smaller values):

Serialnummer = "089501131595900113"

Step1 = Serialnummer / 97

Step2 = Int(Step1) * 97

Step3 = Serialnummer - Step2

Value = Step3 '(Expected number should be 57)

We do the same in MS Access. Then we store the serialnumber in a decimal var(CDec). The problem is that CDec is not available in Bartender.

Can someone help me?

###### Ian Cummings

Your calculation will give you a result of zero in this case as the original number divided by 97 gives you an integer, which when you multiply by 97 gives you back the original number, when you then subtract by the original number you're left with zero.  Did I miss something here?

In general custom check digits are often calculated in the following fashion:

http://seagullscientific.invisionzone.com/index.php?/topic/1549-how-to-create-a-check-digit-using-vb-script/?hl=%2Bcheck+%2Bdigit

###### Melissa Van Niekerk

Hi
I'm new to BarTender and don't know anything about scripts etc.
I need to create 14 digit numeric, sequential barcodes in Codabar symbology format with a check digit.
We supply the first 13 digits and system generates random check digit.
How do i do this?
I've created the sequence etc but can't figure out the check digit.
I also need to know what to input @ number of characters minimum and maximum.

###### Pete Thane

Hi Melissa,

Codabar is a bit of an awkward one as it does not have check digit option in the barcode as standard whilst for most other barcode types this is either added automatically or there is a tick box to enable it/

Not having a standard check digit means that for different applications then a different method can be used to calculate the check digit and sometime with a custom sequence for the check character. There are a number of standard chedk digit algorithms included in BarTender and so if it one of the these the process would be as follows:

• Add you codabar symbol and then go into the Properties of this
• On the Data Source tab click the Change Data Source Name button and when the new screen opens give this string a name, as you can see I have called mine "Hello"
• From the Transforms tab you can access various options including the minimum and maximum settings and this is also where you would go to to serialise the main element of the barcode

• To add the check digit, in the column on left click on the New Data Source button and when prompted change the Source to Visual Basic Script and then make the type Multi-lined script.
• Next click the Edit with Script Editor button
• In the central box type Value = and then on the right expand the Functions and Check Digit and select the type of check digit calculation you need. In the first image below I have chosen the CBarMod16 routine
• As you can see the word String is highlighted as the program is asking you to tell it where the data to apply the CD is coming from. Press the backspace button to delete the word string and this will still leave the cursor between a pair of ( ) brackets
• Again in the column on the right scroll down until you can see Named Data Sources and double click on the name you gave the field earlier to create the connection and so the screen should now look something like the 2nd image.
• Click Close and Close again and then you are done.

If the Check digit you require is not there then a bespoke check digit routine will need to be created.

I hope this helps