# Thread: VBS Math Functions "RoundUp"

1. ## Re: VBS Math Functions "RoundUp"

Hi,
Here's an alternate:
If not x = x mod 10 Then x = x mod 10 +1

hth,
M.

2. ## Re: VBS Math Functions "RoundUp"

Thank you guys
I could do smthg similar my self-See Below- but I'm looking for built-in functions to RoundUp for me.

msgbox RoundUp (3,2)

Function RoundUp(x,y)
If x mod y &lt;&gt; 0 Then
RoundUp = fix(x/y)+1
Else
RoundUp = x/y
End If
End Function

3. ## Re: VBS Math Functions "RoundUp"

Hi,

You can use Split() Funtion
Like
nNumber = 10.8
msgBox Split (nNumber ,".")(0) ' This will print 10

Thanks,
Sreekanth Varma

4. ## Re: VBS Math Functions "RoundUp"

chillyhouse52556, Why do you want a Built-in function when none exist [img]images/icons/wink.gif[/img] ?

5. ## VBS Math Functions "RoundUp"

Round (4.6) = 5
but Round (4.1) = 4
I need to get 5 for both cases , what function other than Round and Fix shall I use?
I could use Fix(4.1)+1 but what if the original value is 4 ? so please execlude Fix from your reply.
Thank you

[ 12-16-2005, 07:36 AM: Message edited by: chillyhouse52556 ]

6. ## Re: VBS Math Functions "RoundUp"

</font><blockquote><font size="1" face="Verdana, Arial, Helvetica">code:</font><hr /><pre style="font-size:x-small; font-family: monospace;"> myNum = 4.1
If (myNum=fix(myNum)) Then
msgbox myNum
Else
msgbox fix(myNum)+1
End If </pre><hr /></blockquote><font size="2" face="Verdana, Arial, Helvetica">

7. ## Re: VBS Math Functions "RoundUp"

Try adding 0.49 before the round
so
Round (4.6 + 0.49) = Round (5.09) = 5
Round (4.1 + 0.49) = Round (4.59) = 5
Round (4.0 + 0.49) = Round (4.49) = 4

8. ## Re: VBS Math Functions "RoundUp"

Tarun
This is what I wanna make sure of "it doesn't exist" because I searched in many VBS books and references and couldn't find it , so I implemented mine and I thought it will be ridicules if I did something which is already there.

9. ## Re: VBS Math Functions "RoundUp"

doesn't fix act the oposite of int on negative numbers or somthing like that.

10. ## Re: VBS Math Functions "RoundUp"

Jon , just add one line as below and it'll work
</font><blockquote><font size="1" face="Verdana, Arial, Helvetica">code:</font><hr /><pre style="font-size:x-small; font-family: monospace;">msgbox RoundUp (-3,-2)

Function RoundUp(x,y)
If x mod y &lt;&gt; 0 Then
If (x&lt;0 and y&gt;0) or (x&gt;0 and y&lt;0) Then
RoundUp = fix(x/y)
Else
RoundUp = fix(x/y)+1
End If
Else
RoundUp = x/y
End If
End Function
</pre><hr /></blockquote><font size="2" face="Verdana, Arial, Helvetica">

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•

vBulletin Optimisation provided by vB Optimise v2.6.0 Beta 4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.