Vb Script To Change Barcode Object Follow

0
Avatar
Legacy Poster

I would like to write a VB script that changes the Bar Code Symbology based on the number of characters in the datasource.

such as:

UPCEAN_len = len(UPCEAN)

If UPCEAN_len = 12 Then
symbology = UPC-A
elseIf UPCEAN_len = 13 Then
symbology = EAN/JAN-13

What exactly would I need to do to change the symbology? Any tips? I am using BarTender Enterprise version 9.01.

Thanks!

5 comments

0
Avatar
Shotaro Ito
Moderator
Comment actions Permalink

Hi dblaron,
BarTender doesn't have an option to change bar code symbology type programmably. Besides, when datasource is empty (""), a bar code won't be printed. So, you can conditionally hide a bar code by create two barcodes on the same place, and give empty string to datasource when condition is met.
You can use OnProcessData script in More Options > VBScript, to modify datasource.

such as,
for UPC-A
[code]
If Len(Value)<>12 Then Value =""
[/code]

for EAN-13
[code]
If Len(Value)<>13 Then Value =""
[/code]

[attachment=55:UPCorEAN.png]
[attachment=56:UPCorEAN.zip]

*Note: Input bar code data with correct checkdigit. From BarTender 9.3, If check digit is incorrect, barcode won't be printed.
if you don't give last digit - give 11 digits to UPC-A or give 12 digits to EAN-13, BarTender automatically append a check digit.

Hope that helps!
0
Avatar
Legacy Poster
Comment actions Permalink

Thank you for your reply, this solution works perfectly.

Also, is there a way I can link a text field to this change as well?

I have a text field above the barcode stating 'UPC-A' and I want it to be shown only above the UPC-A barcode. Similarly, I have a text field stating EAN-13, and I want that to show only above the EAN-13 barcode.

Is there a VB script that can do this?

Thank you again for your assistance!
0
Avatar
Shotaro Ito
Moderator
Comment actions Permalink

Try this..
Create a text using the same data source as the barcode.
On OnProcessData script in More Options > VBScript,
[code]
If Len(Value) = 13 Then Value = "EAN-13"
If Len(Value) = 12 Then Value = "UPC-A"
[/code]
0
Avatar
Legacy Poster
Comment actions Permalink

Only slightly related to this topic, but since I was using this as an example to do what I wanted... I figured my notes might go here...

 

I am merely trying to print a UPC Barcode on a Carton Label only if there is only 1 Stock Code in the Carton.

So I tried the layered approach discussed here...

 

My DataSource either has the value of "MIXED" if there are more than 1 items in the Carton, or the UPC code of the stock code if there is only one...

 

I set up a Text Object to print the "MIXED" when necessary... But I have to print a single blank character to print when I need it blank... Else I get a barcode of the string <empty> printing out...

 

Same with the UPC Code... If the DataSource == "MIXED" and I set it to "", then I get a UPC Code of "<empty>" printing... Instead of nothing... My VBScript for the BarCode Object is ----If value = "MIXED" Then value = ""----

 

This is version 9.10 of Bartender...

0
Avatar
Shotaro Ito
Moderator
Comment actions Permalink

Hi Silvia, would the "<empty>" text actually printed? that might be shown only on design view.

Please sign in to leave a comment.