May 20, 2003 #1 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!!!
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!!!
May 20, 2003 #2 mpastore Programmer Joined Mar 12, 2003 Messages 568 Location US use x=transform(.25) This is VFP6 and greater (I think) Upvote 0 Downvote
May 20, 2003 #3 EzLogic Programmer Joined Aug 21, 2001 Messages 1,230 Location US 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 Upvote 0 Downvote
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
May 20, 2003 #4 rgbean Programmer Joined Nov 9, 2000 Messages 5,707 Location US 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 Upvote 0 Downvote
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
May 20, 2003 1 #5 rccon IS-IT--Management Joined May 13, 2003 Messages 1 Location CA 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. Upvote 0 Downvote
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.
May 20, 2003 Thread starter #6 meny21 IS-IT--Management Joined Oct 4, 2002 Messages 101 Location MX thanks a lot for all your help!!!! Upvote 0 Downvote