get only number from string and find sum in crystal report formula

hello everyone
i want one help from you that  

example   : i have one database field  it contain some value like  

1)   abc-100,abc2-110,defa-200,xyzx-10  
2)   abcd-100,abc1-110
3)   xyza-10,zzz1-150
4)   pqrs-50,
5)   pppzab-150,pabc-150


i want answer like
1)420
2)210
3)160
4)50
5)300

i hope u all are understand and help me to solve that problem in crystal report
please help me friends  i am new for crystal report so please  
thanks


thanks
and regards smit
smit bhavsarAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

James0628Commented:
Based on what you posted, I don't think this will be too difficult, but I don't have time to get into it right now.  I also wanted to check some things.

 Will the values in the field (eg. "abc-100" and "defa-200") always be separated by commas?

 Is the number that you're interested in always at the end of each substring, and always after a "-"?

 If the answer to those questions is "yes", I don't think it will be a problem.  I'll post something later, if someone else doesn't beat me to it.  :-)

 James
smit bhavsarAuthor Commented:
hello jeams
yes you r right value separate by comma and there's  underscore between number and string
if u have any idea about this question answer then plz reply me the answer because i have no idea about crystal report  so please help me

thanks
smit
James0628Commented:
This formula works for your example values.

Local StringVar Array values;
Local NumberVar total;
Local NumberVar i;

values := Split ({your_field}, ",");

for i := 1 to UBound (values) do
  if InStr (values [ i ], "-") > 0 then
    total := total + Val (Split (values [ i ], "-") [ 2 ]);

total

Open in new window


 Use Split to separate the comma-separated values and store them in the values array.
 Loop through the values in the array, and if a value contains a "-", use the "-" to split that value into another array, and use Val to convert the part after the first "-" ( [ 2 ] ) into a number, and add that to total.

 If the field could ever be null, the formula may need to be changed to handle that.

 James

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Crystal Reports

From novice to tech pro — start learning today.