Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Retail Price Round Off
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP2
Network:
Windows 2008 Server
Database:
Visual FoxPro
Application:
Desktop
Miscellaneous
Thread ID:
01499185
Message ID:
01499192
Views:
48
>>Hi Gang!
>>
>>I have some data to convert over, and the data has a field in it, for Retail Price.
>>
>>It is a character field, and has amounts like this.... '2/9.99'
>>
>>So this is 2 for 9.99.
>>
>>I assume they want it to show 4.99, but here is my code I have at the moment (I threw together)....
>>
>>
>>LOCAL lnSlash, lcDivider, lnDivider, lcAmount, lnAmount
>>
>>_SCREEN.Show
>>SET STEP ON 
>>
>>lnSlash = 0
>>lcDivider = ''
>>lnDivider = 0
>>lcAmount = ''
>>lnAmount = 0
>>
>>CLOSE DATABASES 
>>USE "c:\windmill 12-7-10-1" EXCLUSIVE
>>GO top
>>DO WHILE NOT EOF()
>>	IF '/' $ retail
>>		lnSlash = ATC('/',retail)
>>		IF lnSlash > 0
>>			lcDivider 	= LEFT(retail,lnSlash -1)
>>			lnDivider 	= VAL(lcDivider)
>>			lcAmount 	= SUBSTR(retail,lnSlash + 1)	
>>			lnAmount 	= VAL(lcAmount)
>>			IF lnDivider <> 0
>>				lnAmount 	= lnAmount / lnDivider
>>			ENDIF 
>>			lcAmount = ALLTRIM(STR(lnAmount,15,2))
>>			REPLACE retail WITH lcAmount
>>		ENDIF 
>>	ENDIF 
>>	SKIP
>>ENDDO 
>>
>>
>>and the lcAmount comes out as 5.00, not 4.99.
>>
>>So.... any suggestion to make the amounts round down to the lower penny amount?
>>
>>Thanks!
>
>How about:
EVALUATE(STRTRAN(retail,"/","*"))
UPDATE: Won't work. Misread your requirement.

Thanks.... I scratched my head and thought... 'huh???'.... hehehehe... Thanks anyhow!
Tommy Tillman A+ NetWork+ MCP
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform