Question Parse Substring From Barcode with Variable Digit Count (1 Viewer)

kbear954

New member
Local time
Today, 07:29
Joined
Aug 13, 2012
Messages
4
I need to identify and parse (substring) a number of digits from a barcode. The barcode digit count will vary, based on the number of details included in the barcode.

For example: the barcode for GS1 DataBar begins with a 4 digit code of 8110 identifying the code as GS1. The 5th digit then identifies the number of digits directly following which constitute the manufacturers code, which can range anywhere from 6 digits to 12 digits. I need to pull the number of digits out of the barcode based on the value of the 5th digit placeholder and pull only that many digits from the string and replace them into another field. There are potentially 70 total digits in the barcode. I have only provided the first section, which I am asking the question on.

Simply put: I need to tell the substring to identify the number to parse from digit 5, (which will have a min of 6 digits and a max of 12)


How do I pull the information out of a string to create a substring in another field by first defining the number of digits to pull out (Digits 6 to 17 min of 6 digits and a max of 12 digits) based on a value within the string (digit 5= value)


So if Digit 5 is 6 the returned value would be: Digits: 6 7 8 9 10 11 (6 6 6 6 6 6 )


If Digit 6 is 9 the returned value would be: Digits: 6 7 8 9 10 11 12 13 14 (9 9 9 9 9 9 9 9 9)


The first portion of the barcode is below: There are other pieces necessary to be pulled the same way, but from other sections, and based on yet another X desinator field (the next with a min of 1 and max of 5) I assume the pull would be similarly completed.

Please help. I don't know how to write code, I have used formulas but not this detailed or specific.
Ex: I know = Min (barcode, 5, 6) would pull the 6 digits after the 5 spot, but how do I vary the 6 (count) numnber in the formula?

Example below: No additional spaces, dashes, letters etc. (A's = 1-4, X = 5, M's = 6-17)

A A A A X M M M M M M M M M M M M

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
 

Addyman

Registered User.
Local time
Today, 05:29
Joined
Dec 29, 2011
Messages
90
Well, I assume your barcode string is a text string, so you need to grab the 5th digit from it, convert it to an integer value and then use this value to determine how many digits to grab from the barcode string (If I have understood correctly). So something like:

Code:
Dim intLength as integer, strManufacturerCode as string

intLength = CInt(Mid(barcode,5,1)) 

strManufacturerCode = Mid(barcode,5,intLength)

You can then place the value of strMaunfacturerCode into another field or whatever you need to do.

Hope this helps get you started.
 

kbear954

New member
Local time
Today, 07:29
Joined
Aug 13, 2012
Messages
4
I'm assuming from your code indicating "integer" that when you state text field that you're just referring to the type of field property and not an alpha field. Is this a correct assumption? The data is all numeric. Would the text field property be more advantageous than the numeric?

So - I need to pull the 5th digit, have its value verified, and then pull that count of digits directly to the right of digit 5, and ultimately return those digits into another field to pull in the manufacturer from another table.

I'm cool on getting the data into the next field - I just didn't know how to specifiy the number of digits pulled be designated by the 5th digit in the barcode.

If I were using =mid(barcode, 5, #) the # field would be designated by the value of the digit in place 5. I can pull the 5th digit, just don't know how to word the formula to get it so it would, in essence, equal the # in a mid formula.

I'm using GS1 DataBar (one of the new barcodes) which hold a ton more data than the UPC code and have a variable number of digits due to section counts based on the leading digits....

one exaple is: the 5th digit identifies the manufacturer number to follow,

and then for another example: the 24th digit identifies the number of following digits identifying the value of the coupon (this can be from 1 to 5 digits)

The barcode can have anywhere from 27 to 70 characters based on the different "leading" digit values and then the following digit counts.

Did that make sense?

Thank you, BTW, for your help. :)
 

Users who are viewing this thread

Top Bottom