Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Technical Questions
Message Icon Topic: substring formula Post Reply Post New Topic
<< Prev Page  of 2
Author Message
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 09 Apr 2010 at 5:02am
So you want to replace any numeric or blank field field with a ""?
e.g. ("123abc 9 xyz" becomes "abcxyz")
IP IP Logged
lphenderson
Newbie
Newbie
Avatar

Joined: 08 Apr 2010
Online Status: Offline
Posts: 8
Quote lphenderson Replybullet Posted: 09 Apr 2010 at 5:13am
Not quite.  I surely hope this is not impossible with Crystal.  My data looks like the following examples:
 
1 Methadone 2mg
180 253748 SENNA PLUS TAB
12 Heparin Solution 500ml
 
The current formula seems to work fine for the rows with only one 'set' of numbers in front.  The second example row only strips the 180 but leaves the 253748 along with the alpha portion.
lphender
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 09 Apr 2010 at 5:20am
try:
 
mid({OBVARC_txt.DESCRIPTION},
(Local StringVar inString := {OBVARC_txt.DESCRIPTION};
Local NumberVar strLen := Length (inString);
Local NumberVar result := -1;
Local NumberVar a := 1;
While a <= strLen And result = -1 Do
While a <= strLen And result = -1 Do
(
   Local StringVar c := inString [a];
   If NOT (c=" " or NumericText (c)) Then
      result := a;
   a := a + 1;
);
result)
)
IP IP Logged
lphenderson
Newbie
Newbie
Avatar

Joined: 08 Apr 2010
Online Status: Offline
Posts: 8
Quote lphenderson Replybullet Posted: 09 Apr 2010 at 5:27am
Absolutely perfect.  I added one more condition for 'NOT' to eliminate a decimal on one row.  It seems to have covered all the conditions!  I really appreciate you helping me out.
lphender
IP IP Logged
<< Prev Page  of 2
Post Reply Post New Topic
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



This page was generated in 0.035 seconds.