如何在水晶报表中拆分字符串并制作整数数组

如何在水晶报表中拆分字符串并制作整数数组

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

问题描述

我有一个字符串,其中包含一组用_(下划线)分隔的员工 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?

我尝试过使用 split 函数,但仍然不知道如何使用它来创建数组.

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;

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

08-31 00:49