vbscripting, random numbers
I am trying to add a 6 digit random number to a field being pulled from a data source. If the quantity of labels to be printed is (for example), 3, each label needs to have a different random number. I am currnetly getting the same random number on each copy. How do I change this behavior to get a new random number for each print?
Dim upperbound, lowerbound
Randomize
upperbound = 100000
lowerbound = 999999
random = Int( ( upperbound - lowerbound + 1 ) * Rnd + lowerbound )
value = value & random
-
Peter Thane
★ BarTender Hero ★
Add a sequential number field off to the side of the label (ie so it doesn't print) and configure your VB Script as an Event Controlled Script set to OnSerialise
0 -
Ashish Karnani
★ BarTender Hero ★
Hi Peter - I added a sequential number field (and I could actually use that sequential number in place of the 6 digit random number).
How do I chance the VB Script from "OnProcessData" to "OnSerialize" ?
0 -
Ashish Karnani
★ BarTender Hero ★
I did try setting a vbscript in the Document Events' OnSerialize to concatenate the existing value with the 6-digit serial number
Bar Code 2 is the item i'm trying to add the 6-digit serial number (or random number) to and Text 13 is the newly created serialized item which is off the label.
Format.Objects("Bar Code 2").Value = Format.Objects("Bar Code 2").Value & Format.Objects("Text 13").Value
The error I get is : OnSerialize: Unable to write read-only property. How woudl I make "Bar Code 2".Value but updatable, i.e. not read only?
0 -
Peter Thane
★ BarTender Hero ★
You need to make the field itself an Event Controlled VB script routine rather than use a Document Level Script
As in the image above the Text element could be added as a separate substring to the VB element
0
Please sign in to leave a comment.
Comments
4 comments