# Help for VB script needed 追蹤 Christoph Schneider

Hi everbody,

I need to replicate an Interleaved 2 of 5 code from an old Barcode Software to Bartender. It is serial number barcode with 7 digits + 1 check digit.
I have now troubles with the check digit logic in Bartender.

I need to build this logic in VB (I know there are prebuilt logic functions for check digits in the script assistant but unfortunately I don’t know how the following logic is called or even a common on)

Logic to build:

5626187 5 --> 5+6+2+6+1+8+7 = 35 --> check digit is the the second number of the sum so 5
5626188 6 --> 5+6+2+6+1+8+8 = 36 --> check digit is the the second number of the sum so 6
5626189 7 --> 5+6+2+6+1+8+9 = 37 --> check digit is the the second number of the sum so 7
5626190 9 --> 5+6+2+6+1+9+0 = 29 --> check digit is the the second number of the sum so 9
5626191 0 ….
5626192 1 ….
5626193 2 ….
5626194 3 ….

Can someone help me with the code writing for this logic?

BR Christoph

##### 2 意見 ###### Pete Thane

I replied to something similar the other day but that was how to connect up to one of the standard Check Digit calculators so this may help part of the way

https://support.seagullscientific.com/hc/en-us/community/posts/213172188-How-To-Create-A-Check-Digit?page=1#community_comment_1500000324601

I am not sure if any inbuilt calculators match your requirements but if not you will need to create a custom routine.

This is very rough and there is probably a better way of achieving this but (using a named data source as mentioned above this time called "testcode") this works

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

Value1 = Left(Value,1)

Value1 = cint(Value1)

Value2 = Left(Value,2)

Value2 = cint(Value2)

Value2 = Right(Value2,1)

Value3 = Left(Value,3)

Value3 = Right(Value3,1)

Value3 = Cint(Value3)

Value4 = Left(Value,4)

Value4 = Right(Value4,1)

Value4 = Cint(Value4)

Value5 = Left(Value,5)

Value5 = Right(Value5,1)

Value5 = Cint(Value5)

Value6 = Left(Value,6)

Value6 = Right(Value6,1)

Value6 = Cint(Value6)

Value7 = Left(Value,7)

Value7 = Right(Value7,1)

Value7 = Cint(Value7)

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

Value = Right(Value,1)  ###### Christoph Schneider

Good morning Pete,

thanks for the fast reply!
I did try your script and i works well. I will do some more tests to be 100% sure it works an big batches and with the scanning.

I want to thank you soo much, you helped me alot. I really appreciat that.

Have a wonderful day!

BR Christoph