Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Converting a string array to number 1

Status
Not open for further replies.

suemon

IS-IT--Management
Apr 8, 2005
30
GB
Hi all, Hoping someone help.

I am pulling a string field from a notes database that sometimes presents as an array. I need to convert this to numeric in order to total the values.

For example

The field may contain only one value but may alternatively contain more than one. Like so.

1200
or
1200, 350

I need to extract the numbers ... turn them into numbers and then add them up. so that I get the result

1200
or
1550

Is this at all possible with crystal?
 
Try something like:

numbervar i;
numbervar j := ubound(split({table.stringarray},","));
numbervar sumarray;

for i := 1 to j do(
sumarray := sumarray + val(split({table.stringarray},",")));
sumarray;

-LB
 
Works a treat!!!!

Only thing I did different was reset the sumarray to zero so that it didn't give cumulative totals. (see below)

Thanks Lbass ! You have saved the day yet again!

Code:
numbervar i;
numbervar j := ubound(split({table.stringarray},","));
numbervar sumarray [COLOR=red]:=0[/color];

for i := 1 to j do(
sumarray := sumarray + val(split({table.stringarray},",")[i]));
sumarray;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top