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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Remove Dashes From a Number 1

Status
Not open for further replies.

omega1983

Programmer
Dec 21, 2004
32
US
I am using crystal 8.0 (with access to 9.0).
I have an account number as follows 0-62152. I also have a number such as 045842. If the number has a dash I want to show the number without the dash (ie 0-62152, becomes 062152) Is there a quick and dirty way to do this.
 
I tried this formula
Replace ({gifts_full.giftacctno},"-",""). The only problem is that it erases everything so nothing shows. I tried a variation of the formula
Replace ({gifts_full.giftacctno},"-","0"). It then shows the account number without a dash but with an extra zero. Also this field is a string, not a number. Does that change anything?
 
I tried this formula
Replace ({gifts_full.giftacctno},"-",""). The only problem is that it erases everything so nothing shows. I tried a variation of the formula
Replace ({gifts_full.giftacctno},"-","0"). It then shows the account number without a dash but with an extra zero. Also this field is a string, not a number. Does that change anything?

If you have responded to this already, disregard
 
There is a problem with the replace function in 8.0 that was corrected in 8.5. However, I believe there might be a workaround, and I thought Dave (vidru) might have been the one who knew what it was...I myself don't remember.

-LB
 
I'm running 8.5 and 9.0 here, so I can't test with 8 anymore. If you've got access to 9, it should work without any problems there. Unfortunately, if there is a "clean" workaround for 8.0, I don't know what it is.

Here's a "dirty" workaround:

NumberVar i;
StringVar out;
for i := 1 to Len({Table.Field}) do(
if {Table.Field} <> "-" then
out := out + t;);
out;

-dave
 
Looks good to me, Dave*, and it works in 8.0--except I think you meant:

NumberVar i;
StringVar out;
for i := 1 to Len({table.field}) do(
if {table.field} <> "-" then
out := out + {table.field};);
out;

-LB
 
Ah, yes... thanks for the assist, LB. I had tested with a string variable named "t".

-dave
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top