How to split a string and make an array of integers in crystal report
Asked Answered
L

2

7

I have a string with set of employee IDs separated by an _(Underscore). What i want to do is to split that into separate strings and convert them to integers and save them in an integer array. Is this possible in Crystal Reports? Is it possible to convert string into integer/number in Crystal Report?

I have tried using split function but still couldn't figure out how to use it to create an array.

I am very new to crystal report it would be a great help if you could help me out.

Levo answered 16/11, 2012 at 5:5 Comment(0)
L
9
//create an array of strings by parsing a underscore-delimited string field
Stringvar Array strings := Split({table.string_field}, "_");

//empty numeric array; sized to match
Numbervar Array numbers;
Redim numbers[Ubound(strings)];

//populate array
Numbervar i;
for i := 1 to Ubound(strings) do (
  numbers[i] := ToNumber(strings[i])
);

//return
numbers;
Lizalizabeth answered 16/11, 2012 at 14:5 Comment(0)
J
0

split is the correct function. i think it will probably be easiest to keep them as strings and then convert when you need to use them (otherwise you will simply have to loop through the string array and populate a new number array).

what trouble are you having with split? and what do you then intend to do with your array?

Jehovist answered 16/11, 2012 at 10:21 Comment(1)
The problem with the split function was solved.I just didn't knew the proper way to use it. This is the original problem.This is what i want to do with that array. Can you please point me out if there's anything wrong with this formula? #13449389Levo

© 2022 - 2024 — McMap. All rights reserved.