VB Script to validate scanned serial number
Hi,
I want to validate that a scanned bar code contains the correct ID part.
Example of serial number string: S23456ID802W2334
the ID802 is the part that I need to validate before printing, since it can be something else(809,804 etc.)
how could this be done in a VB script?
BR Carsten
-
Peter Thane
★ BarTender Hero ★
Is the part number the whole or part of another label field and if part is it always in a fixed position (ie characters 1 to 3 of the string) ?
You cannot run a VB routine during a prompt/data entry process (I wish you could) but there maybe a way to do something, but will need to mock something up.
0 -
Carsten Frederiksen
★ BarTender Hero ★
The string has its own field. The ID80x is always in the same position: char 9 to 11 of the string. it it helps we could just check the last digit, char no. 11?
When could a VB script run then?
0 -
Peter Thane
★ BarTender Hero ★
Is the ID number value set in a different field somewhere on the label too?
0 -
Carsten Frederiksen
★ BarTender Hero ★
No, but that be made if needed, it could be put on different layer.
0 -
Peter Thane
★ BarTender Hero ★
Yes it would need to be on the template somewhere but it can be off to the side of the label outside of the print area.
Here is a rough mockup I have done
This has 3 forms and 3 named Data Sources and these are
- TheID which is the 3 digit product code as mentioned above
- TheInput that is linked to the scanned input serial number
- TheCheck is a text input field but includes VB as set in the Transforms Use VB option
The base value of this field is sourced from TheInput and then discards all but the first 11 characters of that string and finally just retains characters 9 to 11
Form 1 has the input box into which the scanned serial number is entered whilst the other two forms only display at certain times.
Form 2 contains the number of labels quantity box but the Properties of the Form and the Show When are set as follows:
the TheCheck can be selected from the screen shown but to the TheID part can only be added from the Text View. To configure this select the TheCheck and set the operator to Equals and then click on the Text View and replace the ? with [TheID] .
The Show When for Form 3 is configured in a similar fashion but with a Does Not Equal operator.
Form 3 should have a text field which will tell the users the serial number and product dont match as well as a button that they have to click. Pressing this will return them to Form 1 to re-enter the serial number.
- Add the Button onto the form from the option in Data Entry Control dropdown and then right click and go into the Properties of the button.
- Amend the Text value to suit then click the Actions button
- Select the = next to the Control Clicked and from the options choose the Show Form and then in the box on the right type in Form 1
Hopefully that will get you up and running
0 -
Carsten Frederiksen
★ BarTender Hero ★
thanks 👍, I will try it out in my design and let you know.
0 -
Carsten Frederiksen
★ BarTender Hero ★
Hi Peter, just to let you know, it works perfectly. thanks so much.
0
Please sign in to leave a comment.
Comments
7 comments