Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

VB Script ceiling function (rounding up)?

2,465 views
Skip to first unread message

Russ Ehmke

unread,
Apr 13, 1999, 3:00:00 AM4/13/99
to
Does VB Script have a ceiling function, or a function that will round a
floating point number up to the nearest whole number? Please advise.
Thanks.

Russ Ehmke > microsoft.public.scripting.vbscript > 04/13/99

=====


Eric Lippert (Microsoft Scripting Dev)

unread,
Apr 14, 1999, 3:00:00 AM4/14/99
to
No, but implementing your own is not too hard. One thing you could do is
add 0.5 and then call Round. However, you have to make sure that you check
to see if the number is already a whole number -- otherwise, this will
sometimes round it up to the next whole number which is not what you want.

Something like

Function Ceil(x)
If Round(x) = x Then
Ceil = x
Else
Ceil = Round(x + 0.5)
End If
End Function

Eric

Russ Ehmke <nospa...@ehmke.net> wrote in message
news:#VDsmPch#GA.259@cppssbbsa03...

Russ Ehmke

unread,
Apr 16, 1999, 3:00:00 AM4/16/99
to
Yep. I couldn't find anything in the documentation, but you're right - it's
pretty easy to implement. Thanks.

Russ Ehmke

--

Eric Lippert (Microsoft Scripting Dev) <Eri...@Microsoft.com> wrote in
message news:#XVM86ph#GA...@cppssbbsa02.microsoft.com...

0 new messages