Skip to main content

Search

Search

Define Object Value With Vb If Elseif Statement

Comments

8 comments

  • Avatar
    Shotaro Ito

    Do you want like below?

     

    Print 1 when 350 selected

    Print 2 when 400 selected

    Print 3 when 450 selected

     

    Looks your script works - at least object SKU's value has been updated at preview / print result. What happens when fail?

    0
  • Avatar
    Legacy Poster

    I was getting invalid character at line X error.  I think it is a glitch with the bartender software.  I kept playing around with it and found that if i removed the quotes from the value = result and saved the error went away, but output was invalid.  I then went back in and added the quotes back in to the value result and script began working.  I tried this on multiple objects in the label and the result was that with the removal and re addition of the quotes the script began to work.

     

    I ended up something like this:

     

    Dim X

     

    If Format.Objects("MODEL NAME").Value = "350" Then
    X = "1"
    ElseIf Format.Objects("MODEL NAME").Value = "400" Then
    X = "2"
    ElseIf Format.Objects("MODEL NAME").Value = "450" Then
    X = "3"
    End If

     

    Value = X

     

     

    Now I have another issue though.  This label is 32" in length and when I print the label it starts about 11 inches into the label when it prints, so the first portion of the label is not printed.  We are using Zebra 110 Xi4 printer with current drivers.  I have a similar label with no VB script that is only 4 inches shorter that prints fine.  Max label length is 39 inches according to the software.  Not sure if the script has something to do with the label not printing correctly.

     

    The script I am using is is a bit longer than the sample I posted above.  There are 18 different ElseIf lines in the actual code being used.  And the same format of VB script is being used in 4 different objects on the label to define object outputs.  This one has me stumped... I have checked all printer and driver settings and can't figure out how to get this to work.

     

    Any suggestions would be greatly appreciated.

     

    Thanks,

     

    Chris

    0
  • Avatar
    Domingo Rodriguez
    Moderator
    1. When you say latest printer drivers, do you mean v7.3.6 of the Seagull driver?
    2. Are you printing labels with gaps?
    3. Could you attach the BarTender document (.btw) for us to examine? - Use the "More Reply Options" button for this.
    4. Is the printer properly calibrated? What happens when you press the "Feed" button on the printer several times? Do the labels always start at the same position, shortly after the label gap?
    5. You could also try to perform a "Set Label Length" from the printer driver properties dialog by accessing the "Tools" tab and then going to the "Actions" Drop-Down list.

     

    Also, it should be noted that when making use of the "Format.Objects" object, you should really be using document level VBScript instead:

    http://www.seagullscientific.com/label-software/whitepapers/dynamically-changing-objects-at-print-time-using-vb-script.pdf

    0
  • Avatar
    Legacy Poster

    To answer the questions above...

     

    1. Yes... v7.3.6 of the Seagull driver.

    2. This is a continuous feed printer with cutter, so there are no gaps.

    4. If I push the feed button after printing the label in question, the printer feeds the correct length for the label and cuts the stock.  The printer is properly calibrated... it is used for hundreds of labels on a daily basis.  This is the first time we have seen this issue.

    0
  • Avatar
    Domingo Rodriguez
    Moderator

    Have you tried adjusting any of the below settings under the "File > Print > Document Properties > Stock" dialog?

     

    • Set Top Adjustment.  Specifies the length of label that will be fed
      out or pulled back into the printer before printing a label.  This will offset
      the printed image vertically on the label.  This setting is only changed if the
      checkbox is checked.

       

    • Set Tear-Off Adjustment.  Specifies the length of label that will be
      fed out or pulled back into the printer after printing a label.  This adjusts
      where the label will stop.  This setting is only changed if the checkbox is
      checked.  

       

    0
  • Avatar
    Legacy Poster

    So I figured out the issue of the label not printing completely.  I was using Arial as the font type for everything on the label.  I noticed that when I tried to cache the images and format to the printer it was running out of available memory to cache the images.  It seems that the issue was due to using the true type font which is sent to the printer as images.  I changed all fonts to one of the Zebra fonts and tried to print again (without printer caching enabled) and the label now prints correctly.

    0
  • Avatar
    Legacy Poster

    1. When you say latest printer drivers, do you mean v7.3.6 of the Seagull driver?
    2. Are you printing labels with gaps?
    3. Could you attach the BarTender document (.btw) for us to examine? - Use the "More Reply Options" button for this.
    4. Is the printer properly calibrated? What happens when you press the "Feed" button on the printer several times? Do the labels always start at the same position, shortly after the label gap?
    5. You could also try to perform a "Set Label Length" from the printer driver properties dialog by accessing the "Tools" tab and then going to the "Actions" Drop-Down list.

     

    Also, it should be noted that when making use of the "Format.Objects" object, you should really be using document level VBScript instead:

    http://www.seagullscientific.com/label-software/whitepapers/dynamically-changing-objects-at-print-time-using-vb-script.pdf

     

    You say that I should be using the "Format.Objects" object at the document level VB script instead of using it at the Data Source level.  If that is the case, how do I set the value of an object on the label at the document level VB Script (Label Format Options-VB Scripting)?

     

    I need to set object values based on the value of another object on the label.  It looks like all of the Format.Object objects are read only, so how would a value be set if not through the Data Source VB Script source level?

    0
  • Avatar
    Domingo Rodriguez
    Moderator

    You would give the data source a shared name instead (do this via the "Name" field under the "Data Source" tab for the object's data source, and then assign the value to the named data source instead:

     

    Format.NamedSubStrings("myvar").Value = "P1"

    0

Please sign in to leave a comment.