Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Technical Questions
Message Icon Topic: Count of Characters in Field Post Reply Post New Topic
Author Message
EddiRae
Newbie
Newbie


Joined: 29 Aug 2008
Online Status: Offline
Posts: 30
Quote EddiRae Replybullet Topic: Count of Characters in Field
    Posted: 29 Jan 2009 at 11:14am
I am trying to get a count of the number of Xs in a field.  I am not sure of the best way to achieve this.
 
If someone could help, I would be greatly appreciative.
 
Eddi Rae
IP IP Logged
ricky969
Groupie
Groupie
Avatar

Joined: 03 Jul 2008
Location: United States
Online Status: Offline
Posts: 53
Quote ricky969 Replybullet Posted: 29 Jan 2009 at 11:26am
if you are trying to get the number of characters in a string, you can use the function Len(str).
IP IP Logged
EddiRae
Newbie
Newbie


Joined: 29 Aug 2008
Online Status: Offline
Posts: 30
Quote EddiRae Replybullet Posted: 29 Jan 2009 at 11:29am

I am only looking for the characters of Xs.  If the field contains XXXOOOX ... I want to count the number of Xs, not all the characters in the field.

Thanks for your input!!


Edited by EddiRae - 29 Jan 2009 at 11:30am
IP IP Logged
JohnT
Groupie
Groupie
Avatar

Joined: 20 Jan 2008
Online Status: Offline
Posts: 92
Quote JohnT Replybullet Posted: 29 Jan 2009 at 2:53pm
You could try something like this :
 
local numberVar count:= 0;
local stringVar name := "xxxooox";
Local numberVar strLen:=length(name);
local numberVar I;
for i:=1 to strLen do
    If Mid(name,i,1)= "x"
        then count := count +1;
count

Good luck !
IP IP Logged
EddiRae
Newbie
Newbie


Joined: 29 Aug 2008
Online Status: Offline
Posts: 30
Quote EddiRae Replybullet Posted: 29 Jan 2009 at 3:09pm
That worked perfectly!!!
 
Thank You!!!
IP IP Logged
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.039 seconds.