Always Round Up in VBScript

Results 1 to 2 of 2

Thread: Always Round Up in VBScript

  1. #1
    Join Date
    Dec 1969

    Default Always Round Up in VBScript

    Is there a function that I can use in VBScript that will always round up to the nearest whole number?<BR><BR>Example:<BR><BR>1.00000000000000009 -&#062; 2<BR>1.0 -&#062; 1<BR><BR>Or do I have to do the whole...<BR><BR>if cdbl(dblNumber) - fix(dblNumber) &#060;&#062; 0 then<BR> intResult = fix(dblNumber) + 1<BR>else<BR> intResult = fix(dblNumber)<BR>end if<BR><BR>

  2. #2
    Join Date
    Dec 1969

    Default've got it...

    I&#039;d put it into a function, but other than that you&#039;ve got the right way.<BR><BR>Function RoundUp( num )<BR> num = CDbl(num) &#039; just for sanity<BR> If num = Fix(num) Then RoundUp = num Else RoundUp = Fix(num)+1<BR>End Function<BR>

Posting Permissions

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