Crystal Reports How To — Find a Substring in a String

Peter Musu`
2 min readAug 5, 2020

--

Crystal Reports How To — Find a Substring in a String

Use ‘InStr’ function:

E.g. InStr( {value}, ‘red’ )

From Crystal Reports Help:

InStr Basic and Crystal syntax. Overloads InStr (str1, str2) InStr (start, str1, str2) InStr (str1, str2, compare) InStr (start, str1, str2, compare) Arguments start is the character in str1 where the search is to begin. This is a 1 based index. (This argument is optional.) str1 is the text string to be searched. str2 is the text string being sought within str1. compare is an optional number value indicating which type of string comparison should be used. 0 indicates case-sensitive comparison, and 1 indicates case-insensitive comparison. If this argument is not used, a case-sensitive comparison is performed. Returns Whole Number Action The InStr function returns the position of the first occurrence of one string within another. This position is a 1 based index of the characters in str1. If str2 is not found in str1, the InStr function returns 0. The start argument sets the starting position for the search. If the compare argument is not used, the string comparison will be case-sensitive. Typical uses Use this function to determine if one string contains another. Examples The following examples are applicable to both Basic and Crystal syntax: InStr(“abcdefg”, “bcd”)Returns 2. InStr(3, “abcdefg”, “cde”)Returns 3. InStr(“KarenJudith”,”karen”,1)Returns 1. Note that because the compare argument equals 1, the comparison was case-insensitive. Comments This function is designed to work like the Visual Basic function of the same name. There are two versions of this function, with regards to the start argument. The first does not use the start argument, the second does. If the start argument is not used, InStr searches all of str1 to try to find str2. If the start argument is used, InStr begins searching at the character in str2 indicated by the start argument.

Reference: https://www.itsupportguides.com/knowledge-base/crystal-reports/crystal-reports-how-to-test-if-string-contains/

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

No responses yet

Write a response