Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Number removal from a string Post Reply Post New Topic
Author Message
Chaosphere
Newbie
Newbie


Joined: 27 Apr 2009
Online Status: Offline
Posts: 1
Quote Chaosphere Replybullet Topic: Number removal from a string
     Posted: 27 Apr 2009 at 3:52am
Basically i am trying to remove a certain word & telephone number from a database field which comprises a big description. The location of the word telephone number isnt always the same though they are always the same length.
 
I can remove the word using the Replace function but cannot remove the telephone number. This is how far i have got:
 
if {tbl_name.desc} <> "Number:" THEN
    Replace({tbl_name.desc}, "Number:", "")
 
Doing the same as above but replacing number with "07 " just deletes the first part of telephone number.
 
Thanks in advance for anyone who can help me out!
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 27 Apr 2009 at 7:14am
if you know the length of the number and the identifier is Number:, then you can give this a try:
 
local numbervar phone;
 
phone := instr({tbl_name.desc}, "Number:")
if phone > 0 then
 {tbl_name.desc} := left({tbl_name.desc}, phone-1) + mid({tbl_name.desc}, phone + 6 +lengthOfNumber
 
 
I am not sure about operations on the field itself, I usually place it into a variable, but if has worked, and I can't see why it wouldn't, all the better.
 
If there is more than 1 number in the string, you can loop.  Check the help on how to do that.  It's not hard, but I don't remember how offhand.
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum