Scanning A Character Location From A Prompt Input
Using Bartender 9.3
I am trying to print a label using my prompt design.
For one of my prompt inputs, I want to check a letter that will always be at the same location. Based on what that character is, I determine what a different field should be.
Example:
If I scan "WidgetA1234", I will see the 'A' in the middle and know that the description is "Simple Widget"
If I scan "WidgetB2345", I will see the 'B' in the middle and know that the description is "Super Widget"
My VB attempt:
-
All my VB is self taught so there maybe a simple way to do this but assuming the A or B etc. is always the 7th character then you could you:
1. For your Prompt entry field give this a Share Name. I used testwidget for the code below.
2. For your Super/Simple line set the string to an Event Controlled Post-Prompt script and then Edit it to the following, although for the first line you should select the Named sub-string list from the option at the bottom left of the VB screen (type the Value = and then click on the substring to add it).
Value = Format.NamedSubStrings("testwidget").ValueValue=Left(Value,7)Value=Right(Value,1)If Value = "A" thenValue = "Simple Widget"elseif Value = "B" thenValue = "Super Widget"end ifValue = ValueYou may want to amend the Autoselected Event value (default value before a prompt is entered) to Value = "xxxxx " where xxxx is the default value and you could also add lineElse Value = "No Widget" or similar before the end if line which would be displayed is an A or B was not found at character 7 is in the string.I hope this helps0 -
Thanks! That definitely got me started in the right direction.
Two questions:
1. Merging your example with mine, should the last line be:
Format.NamedSubStrings("IP_Out").Value = Value
2. Your example is using the script located here:
File -> Bartender Document Options -> Visual Basic Script
I was doing mine within the object itself (Text 1 = testwidget):
Text 1 -> Transforms -> VB Script
Any advantages or disadvantages of placing the VB script in one place or the other?
0 -
1. No just leave as Value = Value. That command would set the final value as whatever value is set in the IP_Out and so ignore the calculations above. If you had called the Prompt entry field IP_Out then the first line should be
Value = Format.NamedSubStrings("IP_Out").Value
2. No my example sets the whole Data Source as a VB field rather than Text field with VB Transforms. To be honest I have not had a play with the File -> Bartender Document Options -> Visual Basic Script route and so I just use the method I know that allows me access the Event Controlled Scripts.
0
Bitte melden Sie sich an, um einen Kommentar zu hinterlassen.
Kommentare
3 Kommentare