Visual Basic 6 function "ceil"

Go back

Below you'll find the source for the Visual Basic 6 function ceil.

Attribute VB_Name = "modCeil"
' This function is downloaded from:
' http://www.stefanthoolen.nl/archive/vb6-functions/
' 
' You may freely distribute this file but please leave all comments, including this one, in it.
' 
' @Author Stefan Thoolen <mail@stefanthoolen.nl>

Option Explicit

''
' Round fractions up
' Same syntax as the PHP function 'ceil'
' See also: http://www.php.net/manual/en/function.ceil.php
' @param    Double  value       The nummeric value
' @return   Integer             A ceiled value
' @author   Stefan Thoolen <mail@stefanthoolen.nl>
Public Function ceil(value As Double) As Integer
    Dim i As Integer: i = Round(value)
    If i < value Then i = i + 1
    ceil = i
End Function