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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Rounding

Status
Not open for further replies.

wicker316

Programmer
Oct 22, 2009
1
US
Hello,

Is there a way to round to the next 500 in VFP?

For example..250 would round to 500, 678 would round to 1000, 1234 would round to 1500.

Thanks in advance!

-Rene
 
And again you can also use RoundToUnit as in thread184-1702057 and thread184-1704137

Code:
? RoundToUnit(250,500)
? RoundToUnit(678,500)
? RoundToUnit(1234,500)

Procedure RoundToUnit(tnNumber, tnUnit)
   Return Round(tnNumber/tnUnit,0)*tnUnit
EndProc
And 678 is nearer to 500 so it rounds down, like 1234 also rounds down.

Sometimes the same or very similar questions come in very short after the other. I'm not blaming you for nt browsing through the last few threads, but I often wonder how comes Were you pointed to tek-tips?

Bye, Olaf.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top