Visual Basic 6 function "floor"

Go back

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

Attribute VB_Name = "modFloor"
' 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 down
' Same syntax as the PHP function 'floor'
' See also: http://www.php.net/manual/en/function.floor.php
' @param    Double  value       The nummeric value
' @return   Integer             A floor value
' @author   Stefan Thoolen <mail@stefanthoolen.nl>
Public Function floor(value As Double) As Integer
    Dim i As Integer: i = Round(value)
    If i > value Then i = i - 1
    floor = i
End Function