Microsoft KB Archive/88985

= Converting a Numeric Value to a String =

Article ID: 88985

Article Last Modified on 9/30/2003

-

APPLIES TO


 * Fox Software FoxBASE+ 1.21 for MS-DOS
 * Microsoft FoxBASE+ 2.5 for MS-DOS

-



This article was previously published under Q88985



SUMMARY
When FoxBASE+ converts a numeric value to a string, the numeric is automatically left padded to a length of 10 characters.

For example, if a program contains the following code x = 455 ? STR(x), LTRIM(STR(x)) it returns the following values: &quot; 455&quot;, &quot;455&quot;.

To string numeric values with decimals, include the length of the entire number and the number of decimal places desired to display. The following are examples of using the STR function with numbers that include decimals: x = 234.98 ? STR(x,10,2), LTRIM(STR(x,10,2)) The program returns the following values: &quot; 234.98&quot;,&quot;234.98&quot;.

When doing string comparisons, it is important to make sure the values being compared are in the same format. If the above values are compared, they will not be equal. For example: x=12 ? STR(x)=LTRIM(STR(x))    && returns .F.



MORE INFORMATION
STR([,[,]]) - Changes a numeric value to a                                  string

 - Numeric expression to convert to a character  - Length of the string to return (optional)  - Number of decimal places to use (optional) LTRIM() - Removes all spaces from the left side of a string

 - Character expression

Keywords: KB88985

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.