0

# Vbscript round up every time

Dear all, do you know if it is possible on Vbscipt, to round up every time? For exemple: 1.1->2 1.01->2 19.99->20 Thanks for your help.

3 Answers

+ 1

dear Thomas, i found another way.
myvar = X
result = Fix( X + .99)
Thank you for your help

0

I think, VbScript does not have a native ceilling function.
But maybe you can try this:
Int(1.1) + 1 -> 2
Int(1.01) + 1 -> 2
Int(19.99) + 1 -> 20
But this goes wrong for cases like this:
int(1.0) + 1 -> 2 !
You can write a function:
function Ceil(Number)
Ceil = Int(Number)
if Ceil <> Number
then Ceil = Ceil + 1
end if
end function
This works for all cases
Ceil(1.1) -> 2
Ceil(1) -> 1

0

You are welcome.
Thx for your solution 👍