VB script: find CHARACTER in string
How can I transform data scanned on data entry form by VB scripting??
I need the 12 character after the first semicolon (highlighted bold character) in below samples:
X0403202.22A4;C4C20078540C;221003;1003609
100-05307A;C27000092D18;220411;2099763
The number of characters before and after the necessary bold part is always different.
Thanks in Advance,
Martin
-
Peter Thane
★ BarTender Hero ★
You need to use the InStr command to search for the ; and then take the location of the 1st instance of the semicolon away from the length of the full original string and then just keep the portion of that, such as
Depending on where your data is coming from (ie if from a Database or a Data Entry Form field) then you may need to make the VB field and Event Controlled Script and process the VB at the appropriate time, such as OnNewRecord if from a database etc.
For the example above, to show it working for both string lengths, I added both text strings on to the label and made them Named Datasources (string1 and string2) so I could reference them more easily for the VB. The VB I used is as follows, for string2:
Value = Format.NamedSubStrings("string2").Value
Value1 = Len(Value)
Value2 = Instr(1,Value,";",0)
Value1 = Value1-Value2
Value = Right(Value,Value1)
0
Please sign in to leave a comment.
Comments
1 comment