String Padding Values In Vbscript Follow

0
Avatar
Legacy Poster

Hello I have a simple question.
 
I have several prompts on my label some of the fields must be padded when printed in a 2D barcode, but when displayed in human readable, the padded zeros must not be there. 
 
I can get the label to where all the inputs are combined into a single 2D code with a long sub-string list.
But what is the code to pad these strings either PadRight with blank spaces for characters or PadLeft with 0's for numeric values so that they will appear only when the 2D is scanned. 
 
I think it's a simple line of code but I'm unfamiliar with VB and the help didn't have anything about padding when I searched.

2 comments

0
Avatar
Michael Toupin (mtoupin
Comment actions Permalink

To validate and pad leading zeroes, you'll want to use a VB script like this:

 

If len(value) < 8 then 
Do Until len(value) = 8
value = "0" & value
Loop 
End if
0
Avatar
Legacy Poster
Comment actions Permalink

I had to change it to multi-line script but I was able to get it working properly.The attached shows the final code in case it might help others. 

 

FYI I did have several of these sub-strings to update and I found that the Bartender program frequently crashed during the process on the Script Assistant window. I had to exit and reopen the file, re-do the changes with the same exact code and it let me save. These crashes happened quite often. I think there might be a few bugs with the Script Assistant part of BarTender. Anyhow I was able to go through it carefully and slowly and I was able to produce the label I needed.

 

Thank you for your assistance. 

Please sign in to leave a comment.