Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Decimal to Sring 1

Status
Not open for further replies.

meny21

IS-IT--Management
Joined
Oct 4, 2002
Messages
101
Location
MX
Hi!!!

How can I convert a decimal Variable into String value?

For example:

var1=0.25 I would like to convert it in var1="0.25"

Because when I use x=str(var) or x=str(0.25), the result of x will be 0

Thank you for any help!!!

 
use x=transform(.25)
This is VFP6 and greater (I think)

 
Str(x,Length,Decimal)

where Length is how long you want it to be
and decimal is how many decimal places...

x = 0.05

?str(x,6,2) && 2 decimal places, 6 digit long



Ali Koumaiha
TeknoSoft Inc
Farmington Hills, Michigan
 
Meny21,
Code:
var=0.25
var1 = str(var, 5, 2) && " 0.25"
var2 = transform(var, "99.99") && " 0.25"
These both work in all versions of VFP (and even earlier!)

If you make the field widths wider, you get more spaces, or you can add an LTRIM() to get rid of the leading spaces.

Rick
 
depending on how you want the string to appear
var1=0.25
var2=ltrim(str(var1,10,2))

ltrim removes the leading spaces in the conversion that is 10 characters and the 2 specifies the number of decimal places.

 
thanks a lot for all your help!!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top