Dave
New Member
Be happy!
Posts: 17
|
Post by Dave on Aug 17, 2013 7:14:53 GMT -8
I received an e-mail from an individual, asking a VBScript question. I wanted to assist her, and share this answer with anyone else who may have the same question, so here it is:
------------------------------------------------------------------------------------ I am pulling a field from an Access database and want to format the field differently than it is in the database. The field comes into the database like this: 1234567891234 and I want it to appear in a BarTender label like this: 123-4-567891-23-4. I am a newbie to VB, but BarTender supports VB scripts, so this is how I have to do this. Can you help me? ----------------------------------------------------------------------------------
|
|
Dave
New Member
Be happy!
Posts: 17
|
Post by Dave on Aug 17, 2013 7:16:49 GMT -8
' fmtfield.vbs - Reformat a field ' Convert 1234567891234 to 123-4-567891-23-4
Option Explicit
Dim ipField, opField
ipField = 1234567891234
opField = mid(ipField,1,3) & "-" & mid(ipField,4,1) & "-" & mid(ipField,5,6) & "-" & _ mid(ipField,11,2) & "-" & mid(ipField,13,1)
wscript.echo ipField & "=" & opField WScript.quit
Enjoy Dave
|
|
|
Post by Lori on Aug 17, 2013 7:35:13 GMT -8
Since the database field will vary in its contents, don't I need to identify the database field somewhere in the script?
|
|
Dave
New Member
Be happy!
Posts: 17
|
Post by Dave on Aug 18, 2013 21:26:11 GMT -8
Yes. Whatever your field is is represented in IpField above (instead of assigning it with a literal value of 1234567891234).
|
|