Vbscript round up every time | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
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.

27th Dec 2019, 12:02 PM
Abdel
Abdel  - avatar
3 Answers
+ 1
dear Thomas, i found another way. myvar = X result = Fix( X + .99) Thank you for your help
27th Dec 2019, 1:31 PM
Abdel
Abdel  - avatar
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
27th Dec 2019, 12:24 PM
Coding Cat
Coding Cat - avatar
0
You are welcome. Thx for your solution 👍
27th Dec 2019, 2:02 PM
Coding Cat
Coding Cat - avatar