如何拆分一个字符串并在水晶报表中创建一个整数数组 [英] How to split a string and make an array of integers in crystal report

查看:637
本文介绍了如何拆分一个字符串并在水晶报表中创建一个整数数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个由_(下划线)分隔的雇员ID集合的字符串。
我想做的是将它拆分成单独的字符串,并将它们转换为整数,并将其保存在整数数组。
这是否可能在水晶报表?
是否可以在Crystal Report中将字符串转换为整数/数字?

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.

推荐答案

//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;

这篇关于如何拆分一个字符串并在水晶报表中创建一个整数数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆