Strings


String (or text) functions allow you to control text strings within formulas. For example, these functions allow you to determine the length of a text string or join date information to a text string.

Table C-5: String functions

Function

Description

Arguments

Len (str)

Returns the number of characters in a text string.

Len and Length are equivalent. However, Len is preferred in Basic syntax, whereas Length is preferred in Crystal syntax.

str is the text whose length you want to find. Spaces count as characters.

Length (str)

Returns the number of characters in a text string.

Len and Length are equivalent. However, Len is preferred in Basic syntax, whereas Length is preferred in Crystal syntax.

str is the text whose length you want to find. Spaces count as characters.

Trim (str)

Removes all spaces from text except for single spaces between words.

str is the text from which you want spaces removed.

LTrim (str)

Removes all spaces stored to the left of the given string and returns it.

LTrim and TrimLeft are equivalent functions. However, LTrim is preferred in Basic syntax, whereas TrimLeft is preferred in Crystal syntax.

str is the text from which you want spaces removed (from the left of the text).

TrimLeft (str)

Removes all spaces to the left of a string or data field, which is stored as a right-justified string in a database.

LTrim and TrimLeft are equivalent functions. However, LTrim is preferred in Basic syntax, whereas TrimLeft is preferred in Crystal syntax.

str is the text from which you want spaces removed (from the left of the text).

RTrim (str)

Removes all spaces to the right of the given string and returns it.

RTrim and TrimRight are equivalent functions. However, RTrim is preferred in Basic syntax, whereas TrimRight is preferred in Crystal syntax.

str is the text from which you want spaces removed (from the right of the text).

TrimRight (str)

Removes all spaces to the right of the given string and returns it.

RTrim and TrimRight are equivalent functions. However, RTrim is preferred in Basic syntax, whereas TrimRight is preferred in Crystal syntax.

str is the text from which you want spaces removed (from the right of the text).

UCase (str)

Converts text to uppercase.

UCase and UpperCase are equivalent functions. However, UCase is preferred in Basic syntax, whereas UpperCase is preferred in Crystal syntax.

str is the text you want converted to uppercase. Text can be a reference or text string.

UpperCase (str)

Converts text to uppercase.

UCase and UpperCase are equivalent functions. However, UCase is preferred in Basic syntax, whereas UpperCase is preferred in Crystal syntax.

str is the text you want converted to uppercase. Text can be a reference or text string.

LCase (str)

Converts all uppercase letters in a text string to lowercase.

LCase and LowerCase are equivalent functions. However, LCase is preferred in Basic syntax, whereas LowerCase is preferred in Crystal syntax.

str is the text you want to convert to lowercase. LCase does not change characters in text that are not letters.

LowerCase (str)

Converts all uppercase letters in a text string to lowercase.

LCase and LowerCase are equivalent functions. However, LCase is preferred in Basic syntax, whereas LowerCase is preferred in Crystal syntax.

str is the text you want to convert to lowercase. LowerCase does not change characters in text that are not letters.

ProperCase (str)

Capitalizes the first letter in a text string and any other letters in text that follow any character other than a letter. Converts all other letters to lowercase letters.

str is text enclosed in quotation marks, a formula that returns text or a reference to a cell containing the text you want to partially capitalize.

StrReverse (inputString)

Returns a String in which the character order of inputString is reversed. If inputString is a zero-length string (""), a zero-length string is returned.

inputString is a string whose characters are to be reversed.

IsNumeric (str)

Returns True if the String argument can be converted to a Number. Otherwise, the function returns False.

str is a string value to be tested.

NumericText (str)

Tests to see if the content of a text object is a Number.

str is a text string being tested for numeric text.

ToNumber (numeric)

ToNumber (string)

ToNumber (Boolean)

Converts a Number, Currency, text string, or Boolean value to a Number.

CDbl and ToNumber are equivalent functions.

numeric is a Number or a Currency type value.

string is a text string that holds numeric text.

Boolean is a Boolean value that you want to treat as a number.

ToText (x, y, z, w, q)

Converts Numbers, Currency, Date, Time, and DateTime values to text strings.

CStr and ToText are equivalent functions.

Boolean Values:

x is a Boolean value that is converted to a String, either "True" or "False."

Number and Currency Values:

x is a Number or Currency value to be converted into a text string; it can be a whole or fractional value.

y is a whole number indicating the number of decimal places to carry the value in x to. (This argument is optional.)

z is a single-character text string indicating the character to be used to separate thousands in x. The default is the character specified in your International or Regional settings control panel. (This argument is optional.)

w is a single-character text string indicating the character to be used as a decimal separator in x. The default is the character specified in your International or Regional settings control panel. (This argument is optional.)

Number and Currency Values (formatting):

x is a Number or Currency value to be converted into a text string; it can be a whole or fractional value.

y is a text string used to indicate the format for displaying the value in x.

z is a whole number indicating the number of decimal places to carry the value in x to. (This argument is optional.)

w is a single-character text string indicating the character to be used to separate thousands in x. The default is the character specified in your International or Regional settings control panel. (This argument is optional.)

q is a single-character text string indicating the character to be used as a decimal separator in x. The default is the character specified in your International or Regional settings control panel. (This argument is optional.)

Date Values:

x is a Date value to be converted into a text string.

y is a text string that defines how the value in x is to be formatted.

Time Values:

x is a Time value to be converted into a text string.

y is a text string that defines how the value in x is to be formatted.

z is a text string to be used as a label for A.M. (morning) hours. (This argument is optional.)

w is a text string to be used as a label for P.M. (evening) hours. (This argument is optional.)

DateTime Values:

x is a DateTime value to be converted into a text string.

y is a text string of characters that indicate how the resulting text string will be formatted.

z is a text string to be used as a label for A.M. (morning) hours. (This argument is optional.)

w is a text string to be used as a label for P.M. (evening) hours. (This argument is optional.)

ToWords (x)

ToWords (x, #places)

ToWords (x, #places, formtype)

Converts a Number or Currency field value or the result of a numeric calculation to words so it can be used as text. The ability to adjust the number of decimal places can be useful when the number is the result of a calculation that may produce more decimal places than you want.

x is a fractional Number to be converted into words.

#places is a whole number indicating the number of decimal places to be converted. (This argument is optional.)

formtype specifies what type of form x is. This argument is used only for Asian languages—specifically, Japanese, Korean, Simplified Chinese, and Traditional Chinese. It is ignored for English or any other non-Asian language.

ReplicateString (str, #copies)

Replicates the string in str the number of times specified by #copies.

str is the text string to be replicated.

#copies is a whole number indicating the number of times str is to be replicated.

Space (x)

Returns a specified number of spaces.

x is a whole number indicating the number of spaces.

InStr (str1, str2)

InStr (start, str1, str2)

InStr (str1, str2, compare)

InStr (start, str1, str2, compare)

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.

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.

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.

InStrRev (inputString, findString)

InStrRev (inputString, findString, startPosition)

InStrRev (inputString, findString, startPosition, compare)

Indicates the position of the matching string in the string to be matched. The first character of inputString (from the beginning) is 1.

inputString is a String expression being searched.

findString is a String expression being searched for.

startPosition is an optional numeric expression that sets the starting position for each search. If omitted, -1 is used, which means that the search begins at the last character position.

compare is an optional numeric value indicating the kind of comparison to use when evaluating substrings:

0 performs a comparison that is case sensitive.

1 performs a comparison that is case insensitive.

If omitted, a case-sensitive comparison is performed.

StrCmp (str1, str2)

StrCmp (str1, str2, compare)

Compares two strings.

str1 is the first text string to be compared.

str2 is the second text string to be compared.

compare is an optional Number value indicating the kind of string comparison to use:

0 performs a comparison that is case sensitive

1 performs a comparison that is case insensitive

If omitted, a case-sensitive comparison is performed.

Mid (str, start, length)

Returns a specific number of characters from a text string, starting at the position you specify, based on the number of characters you specify.

str is the text string containing the characters you want to extract.

start is the position of the first character you want to extract in text. The first character in text has start 1 and so on.

length specifies the number of characters you want Mid to return from text.

Left (str, length)

Returns the first character or characters in a text string, based on the number of characters you specify.

str is the text string that contains the characters you want to extract.

length specifies the number of characters you want to extract.

Right (str, length)

Returns the last character or characters in a text string, based on the number of characters you specify.

str is the text string containing the characters you want to extract.

length specifies the number of characters you want to extract.

Val (str)

Converts a text string that represents a number to a number.

str can be in any of the constant number, date, or time formats recognized by Crystal Reports.

Chr (x)

Returns the character specified by a number.

x is a number from 1 to 255 specifying which character you want. The character is from the character set used by your computer.

ChrW (x)

Returns the single-character text string associated with the Unicode value passed in as x.

x is a whole number, specifically, any Unicode value. x must be from 0 to 65535, or you will get a numeric overflow error.

Asc (str)

For Double-byte character set (DBCS) languages, changes half-width (single-byte) English characters to full-width (double-byte) characters.

str is the text or a reference to a cell that contains the text you want to change. If the text does not contain any full-width English letters, it is not changed.

AscW (str)

Returns the Unicode value of the first character of the string.

str is the text or a reference to a cell that contains the text you want to change. If the text does not contain any full-width English letters, it is not changed.

Filter (inputStrings, searchString)

Filter (inputStrings, searchString, include)

Filter (inputStrings, searchString, include, compare)

Searches an array of strings for a specified string and returns the strings in an array.

inputStrings is an array of strings to be searched.

searchString is a string to search for.

include is an optional Boolean value indicating whether to return substrings that include or exclude searchString.If include is True, Filter returns the subset of the array that contains searchString as a substring. If include is False, Filter returns the subset of the array that does not contain searchString as a substring. If omitted, the value True is assumed.

compare is an optional Number value indicating the kind of string comparison to use:

0 performs a comparison that is case sensitive.

1 performs a comparison that is case insensitive.

If omitted, a case-sensitive comparison is performed.

Replace (inputString, findString, replaceString)

Replace (inputString, findString, replaceString, startPosition)

Replace (inputString, findString, replaceString, startPosition, count)

Replace (inputString, findString, replaceString, startPosition, count, compare)

Replaces part of a text string, based on the number of characters you specify, with a different text string.

inputString is text in which you want to replace some characters.

findString is a substring being searched for.

replaceString is the text that will replace characters in the old text.

startPosition is the position of the character in the old text that you want to replace with the new text.

count is the number of characters in old_text that you want Replace to replace with the new text.

compare is an optional Number value indicating the kind of string comparison to use:

0 performs a comparison that is case sensitive.

1 performs a comparison that is case insensitive.

If omitted, a case-sensitive comparison is performed.

Join (list)

Join (list, delimiter)

Returns a String created by joining a number of substrings contained in an array.

list is a String array containing substrings to be joined.

delimiter is an optional String used to separate the substrings in the returned string. If omitted, the space character (" ") is used. If delimiter is a zero-length string (""), all items in the list are concatenated with no delimiters.

Split (inputString)

Split (inputString, delimiter)

Split (inputString, delimiter, count)

Split (inputString, delimiter, count, compare)

Takes a String that contains a number of substrings, breaks it up into a specified number of substrings, and returns an array containing the substrings.

inputString is a String expression containing substrings and delimiters.

delimiter is an optional String character used to identify substring limits. If omitted, the space character (" ") is assumed to be the delimiter. If delimiter is a zero-length string, a single-element array containing the entire inputString string is returned.

count is an optional number value of substrings to be returned. The value -1 indicates that all substrings are returned. If omitted, -1 is assumed.

compare is an optional Number value indicating the kind of string comparison to use:

0 performs a comparison that is case sensitive.

1 performs a comparison that is case insensitive.

If omitted, a case-sensitive comparison is performed.

Roman (arabicVal, form)

Converts an Arabic numeral to a Roman numeral, as text.

(no arguments)




Mastering Business Analysis with Crystal Reports 9
Mastering Business Analysis with Crystal Reports 9 (Wordware Applications Library)
ISBN: 1556222939
EAN: 2147483647
Year: 2004
Pages: 177
Authors: Chris Tull

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net