INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login




Remember Me
Forgot Password?
Join Us!

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.
Jobs from Indeed

Link To This Forum!

Partner Button
Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Remove Dashes From a Number

Remove Dashes From a Number

(OP)
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.

RE: Remove Dashes From a Number

Yep:

Replace({Table.Field},"-","")

-dave

RE: Remove Dashes From a Number

(OP)
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?

RE: Remove Dashes From a Number

(OP)
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

RE: Remove Dashes From a Number

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

RE: Remove Dashes From a Number

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}[i] <> "-" then
    out := out + t[i];);
out;

-dave

RE: Remove Dashes From a Number

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}[i] <> "-" then
    out := out + {table.field}[i];);
out;

-LB

RE: Remove Dashes From a Number

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

-dave

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close