Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Retail Price Round Off
Message
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Retail Price Round Off
Versions des environnements
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP2
Network:
Windows 2008 Server
Database:
Visual FoxPro
Application:
Desktop
Divers
Thread ID:
01499185
Message ID:
01499185
Vues:
112
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!
Tommy Tillman A+ NetWork+ MCP
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform