Hello
can anyone tell me if the result of a calculation returns a value of say 62.05 (could be anything)is it possible to use the round function to make the result always round up eg:63 rather than 62?
Thanks
Printable View
Hello
can anyone tell me if the result of a calculation returns a value of say 62.05 (could be anything)is it possible to use the round function to make the result always round up eg:63 rather than 62?
Thanks
Why not do this?
Code:Rounded = Int(Number + 1)
One way to always make a real value round up is to use the Int() function (which always rounds down on positive numbers) and just add one to your result. For example:
PaulCode:Dim dblNumber As Double
Dim intResult As Integer
dblNumber = 62.05
intResult = Int(dblNumber) + 1
MsgBox intResult ' Displays 63
PS - Looks like oetje and I posted the same reply at the same time! :P
Something to be aware of if you are wanting to
keep the whole number and disregard the .xx
Code:Dim x as double
x = 62.65 'if .xx more than .5x
msgbox round(x) + 1 'returns 64
msgbox cint(x) + 1 'returns 64
msgbox fix(x) + 1 'returns 63
fix always reverts to the whold while cint,round, will
go higher if fraction over 5