VBscript to replace a "dot" decimal with a "comma" decimal
We recently installed BT 2022 and trying to upgrade BT 9.4 formats to BT2022 64-bit (currently working as 32-bit, but using 32-bit DLL that can't be upgraded). Need to modify VB scripts to replace a weight value, saved as text with "dot" decimal to use a "comma" decimal based on Customers regional location value.....Example function using Excel: =REPLACE(Value,4,1,",")
I was successful using BarTenders built-in options with Date formats, but struggling getting this one to work.
Current scripts only return the "dot" decimal, even when I have defined the text format to show the "comma". Tried the Numeric format, but didn't find a way to specify the required decimal, so resorting to VBscript and can suppress the unused value based on Regional setting if I can just get BT to print a "comma" decimal like the DLL code provides.
fld = Value |
fld = Field("T_ALPS_SHIPMENT_LABEL.F_NET_WEIGHT_KG") |
condition = Field("F_REGIONAL_SETTING") |
if condition = "34" then |
fld = Value |
else |
Value = "" |
end if |
====================================================== |
fld = Value |
fld = Field("T_ALPS_SHIPMENT_LABEL.F_NET_WEIGHT_KG") |
condition = Field("F_REGIONAL_SETTING") |
if condition <> "34" then |
fld = Value |
else |
Value = "" |
end if |
-
Hello Bill,
Thank you for reaching us via our Community Forums.
Would it be possible to use the replace function for VB script in order to achieve this? I presume somewhere after the if condition you could add the following:str = Replace(str, ",", ".")
I hope this helps!0 -
Bill Bridendall
★ BarTender Hero ★
Thank you for your suggestion as Bartender Support did not suggest an alternative Bartender method to define the decimal and I thought it could be done with a VBscript but I'm not a programmer.
0 -
Jose Adam Flores Sr.
★ BarTender Hero ★
Hello Bill,
I have noticed that your vbScript issue still not working,
Although I'm not a full fledged programmer I do use a lot of vbScripts succesfuly
if you could upload a copy of your BarTender format and a copy of your data Source (Maybe exported to a CSV
in case your data is in a Database)
I'll do my best to help you resolve your issue.
Regards.
Adam Flores Sr.
0 -
Bill Bridendall
★ BarTender Hero ★
Thank you for your offer, I'm currently trying to get in touch with other IT resources of the company I'm contracted with to stay within their security rules. I think it is a simple change and was able to test the concept with Excel using the standard REPLACE function. Might try to create separate entries and use the BT Suppress option to hide the one that doesn't apply......worked for Date formats. If that doesn't work will mock-up a simpler format with the current logic and put some data into a spreadsheet to use as a database to post online...no violation of company policy if I go that route.
Regards,
Bill Bridendall
0 -
Peter Thane
★ BarTender Hero ★
I don't think you need to use VB but can use Suppression instead.
- Add a 2nd identical template to you label but for the date set the type to Custom from the dropdown date options and type in the dd MM yy with commas in between instead of dots, ie dd.MM.yy
- Go to the Properties of your original template and set the Print When to Conditionally based on expression and select your field in the database that includes the 34 and use the Does Not Equal parameter (I used select by data source in the image below as I used a Named field rather than a database object)
- Repeat this process for the 2nd template but use the equals parameter
0 -
Bill Bridendall
★ BarTender Hero ★
Thanks for the guidance on the conditional Template options. I did something similar with Date formatting and was hoping to use that concept to revise weight data for different global regions which prefer to use the "dot" decimal or the "comma" decimal. We define formats by Customer "Ship-To" Site with a Regional setting, similar to Date formatting to meet their preference. I would very much prefer a solution that required no VB code as becomes harder to get future support given changing support personnel over the past 25 years. BT 2021/22 has greater flexibility to handle those changes and why I am trying to eliminate the 32-bit custom DLL we had been using for years with BT 9.4.
Regards, Bill
0
Please sign in to leave a comment.
Comments
6 comments