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

Rounding up or down currency

Status
Not open for further replies.

abselect

MIS
Jan 5, 2002
5
GB
Firstly from a database I get £23,26 then I wish to give a 20% dicount but I want to keep the final sum free of last penny ie: ##,#0.

I a trying to round up or down ie: 23.26 to 23.30
or down ie: 23.24 to 23.20

I have tried to to divide by five untill no decimal is encountered, also interigating dblvar = format(##.##) with little sucsess
am I supposed to interigate individual digits if so how?
Apreciate any help.
abselect



 
Hi,

You could use the Round() function but if a 5 must be rounded, the function cuts back the number. This is not correct.
So you could use this function

Function xRound(ByVal Num, ByVal NumDec As Integer)
Afrond = Int(Num * 10 ^ NumDec + 0.5) / 10 ^ NumDec
End Function

Hope this helps
Good luck
 
The round function uses banking rounding.

evens round down, odds round up
text1 = round(text1,1)

22.45 rounds to 22.4
22.55 round to 22.6 David Paulson

 
Hi,

I made a type error


Function xRound(ByVal Num, ByVal NumDec As Integer)
xRound= Int(Num * 10 ^ NumDec + 0.5) / 10 ^ NumDec
End Function

'You can use the function like this

Text1 = xRound(Text1,1) '1 is the number of decimals you
' want
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top