How to count number of Spaces in String on Crystal reports

Posted on Posted in .NET

For example consider you have a string “This is a String” and you want to count the number of Spaces in this string? then the solution is here!

To count the number of spaces in a given string using crystal reports use the following code in the forumula field.

 

Length({Table.FieldName})-Length(Replace({Table.FieldName} ,” ” ,””))

 

Thats it!

the result for the string  “This is a String” will be returned 3.

 

Have any doubts?, put them in comments

Leave a Reply

Your email address will not be published. Required fields are marked *