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

最后都变了- 提交于 2019-11-30 21:48:13
//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;

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?

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!