Click to See Complete Forum and Search --> : bad characters in data


newgirl
November 19th, 2007, 04:04 PM
I need to pull the amount of a fee that was paid out of a string. Most of the data is good, but some typos occurred in the input, such as:
$800.00.
$700.0+
$850.

All the amounts start with the "$". I need to pull out the amount paid and put it into a field that can be summed up.

(field names edited for clarity) -- So far, I have:

if {(position-of-$} > 1

then
{StringName} [({position-of-$dollar sign position}+1) to ({position-of-$}+6)]

That is it. When I tried to change the result to a number, I get error messages saying "string is not a number".

How can I clean up the right hand side of the data?

Using Crystal Reports 9.

Thanks!

jggtz
November 19th, 2007, 05:55 PM
1.- Find the position of period
2.- Trim $ sign and characters right of period
3.- Convert to number

Make the neccesary changes (replace stringVar X with your field)


stringVar X := "$850.0" ;
numberVar I := InStr(X,".") ;
stringVar Y := Mid(X,2, I-1) ;
numberVar N := Val(Y);