### ToText

Basic and Crystal syntax.

ToText and CStr are equivalent functions.

##### Overloads

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

##### Arguments

Converting . . . | Description
--- | ---
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. 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. 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. See Format Strings for information on creating a format string. 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. 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. See Format strings for Date, Time, and DateTime values for more information on creating this format string. (This argument is optional.)
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. See Format strings for Date, Time, and DateTime values for more information on creating this format string. (This argument is optional.) 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. See Format strings for Date, Time, and DateTime values for more information on creating a format string. (This argument is optional.) 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.)

##### Returns

Text String

##### Action

The ToText function converts Numbers, Currency, Date, Time, and DateTime values to text strings.

##### Typical uses

Use this function to convert a Number, Currency, Date, Time, or DateTime value to a text string to appear as text in your report (form letters, comments, etc.).

##### Examples

The following examples are applicable to both Basic and Crystal syntax:

`ToText({orders.SHIPPED})`

Returns True where the value in ({orders.SHIPPED}) is True.

`ToText(123.45)`

Returns "123.45".

`ToText(12345.6749,2)`

Returns "12345.67".

`ToText(12345.6750,2)`

Returns "12345.68".

`ToText(12345.4999,0)`

Returns "12345".

`ToText(12345.5000,0)`

Returns "12346".

`ToText({file.AMT} * {file.QUANTITY})`

Returns 44,890.20 where Amt = 24.45 and Quantity = 1836.

ToText is useful when you want to build a sentence by combining (concatenating) a converted Number or other value with other text strings:

`"The base price of item # " + {file.ITEM NUMBER} + " is $" + ToText({file.BASE PRICE}) + "."`

Prints the sentence "The base price of item A1/4520/B12 is $50.00." where the Item number is A1/4520/B12 and the Base Price is 50.00, converted to text and formatted with two decimal places.

The following examples are applicable to Crystal syntax:

`ToText(CDate(1996, 11, 1), "yy MMM dd, dddd")`

Returns 96 Nov 01, Monday.

`ToText(DateTime(1995,10,12,3,30,11),"HH:mm, yy MMMM ddd")`

Returns 03:30, 95 October Mon.

`ToText(Time(12, 10, 10), "HH*mm*ss tt", "amStr", "pmStr")`

Returns 12*10*10 pmStr.

Seagate Software, Inc. http://www.seagatesoftware.com Please send comments to: techpubs@seagatesoftware.com