kelsanit
asked on
Crystal - Return values in string seperated by & sign into seperate fields
I have a crystal report with a string that is seperated by & signs. I am wanting to seperate the string into diffrent fields so i can use in other functions.
Example:
String: 06/01-120&06/01-228&06/02- 300&6/5-30 0
Expected output:
Value1 = 06/01-120
Value2 = 06/01-228
Value3 = 06/02-300
Value4 = 06/05-300
Example:
String: 06/01-120&06/01-228&06/02-
Expected output:
Value1 = 06/01-120
Value2 = 06/01-228
Value3 = 06/02-300
Value4 = 06/05-300
If the number of values in the field can vary, you can use UBound to test how many values there are, to avoid getting a subscript error. For example, if the field contained "06/01-120&06/01-228", that would give you an array with 2 elements, so Split ({field}, "&") [ 3 ] would give you an error. You can avoid that by using something like this:
if UBound (Split ({field}, "&")) >= 3 then
Split ({field}, "&") [ 3 ]
James
if UBound (Split ({field}, "&")) >= 3 then
Split ({field}, "&") [ 3 ]
James
ASKER
There could be only one value in the field or 3 or 4. I tried adding the UBound to the first part of the formula but returned 0 results. When i use the original formula provided it just give me error "A subscript must be between 1 and the size of the array"
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
This worked perfect!
Thank you.
Thank you.
Split({YourField},'&')
You can then display them individually with Split({YourField},'&')[1]
To preserve the values for use in other formulas create a formula
Open in new window
In another formula you can display the values
Open in new window
mlmcc