Zum Hauptinhalt gehen

Suche

Suche

How to remove only specific leading characters

Kommentare

7 Kommentare

  • Avatar
    Peter Thane

    If it is the leading digit for all the codes then you could just use the Transforms>Truncation and discard the leading character

    0
  • Avatar
    Troy Harkness

    Unfortunately, not all the characters are the leading digit on all Item Numbers. Some of the Item Numbers start with a number or letter. The special characters will show up in the middle of the Item Number as well but the characters in the middle need to stay there and not get stripped out. 

    0
  • Avatar
    Peter Thane

    So it looks like you are wanting to do something like this

    To do this you will need to add some VB that looks for the *, or - or # as starting characters only and strips them off and this does the trick:

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

    Value1 = Len(Value)

    Value2 = Value1-1

    Value3 = Left(Value,1)

    If Value3 = "#" then

    Value = Right(Value,Value2)

    elseif Value3 = "-" then

    Value = Right(Value,Value2)

    elseif Value3 = "*" then

    Value = Right(Value,Value2)

    else Value = Value

    end if

    Value = Value

     

    The first line should be replaced by linking the Value = command to the field that has the full number in it, either as a Named source like I am using or else a Database field that will appear in the Script Assistant column box if your label is connected to a database. Note, for the Named data source option the field does not have to be on the printed label but can be added to the side of the printed area and so the VB can reference it even if you don't want the full value printed.

     

     

     

    1
  • Avatar
    Troy Harkness

    I am obviously using an older version of bartender 10.0 if that matters. 

    I have tried a few different combinations trying to get this to run. No matter what I try to place in the Format.Substrings("NoOne").Value I get basically the same error. It calls out whatever I place in it as not found in the Named Data Sources. I have included the named Data Sources to see it. There is nothing in it. 

    0
  • Avatar
    Peter Thane

    You would need to create the Named Data Source first (or at least give the field a name). I think that option maybe on the Data Source tab of the Text Properties screen but I could be wrong as it is has been a number of years since I last used v10.0. Saying that as I think you are linking to a database field then you wont need to do this as you can reference the DB field from the Category list at the bottom of the VB screen. However, you are using the wrong VB option I believe as you are applying the VB to the data not manipulating the data to suit, if that makes sense.

    The Data Source of the field needs to be Visual Basic Script and not Database and then the "type" (I think it is) should be set to Event Controlled Script and OnNewRecord so that the VB is applied when a new database record is selected. The code can then be pasted into the similar box to the above with line one edited to select the right database field

    0
  • Avatar
    Troy Harkness

    I was able to get the label files into the newer version of bartender. The script worked as you described. Saved the file as older version 10.1 and the script did no longer worked. 

    Troy

     

     

     

    0
  • Avatar
    Troy Harkness

    Never mind it did work. Sorry for the miss leading message above. I was not outputting the file to see the result. I was relying on the hardcoded info I used as sample data on the label. When I ran it through to print preview it worked.

    Thank you for all the help. 

    Troy

    0

Bitte melden Sie sich an, um einen Kommentar zu hinterlassen.