Visual Basic 6 function "rand"

Go back

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

Attribute VB_Name = "modRand"
' 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

''
' Generate a random integer
' Same syntax as the PHP function 'rand'
' See also: http://www.php.net/manual/en/function.rand.php
' @param    Integer Min             The minimum value
' @param    Integer Max             The maximum value
' @return   Integer                 A value between Min and Max or equal to Min or Max
' @author   Stefan Thoolen <mail@stefanthoolen.nl>
Public Function rand(Min As Integer, Max As Integer) As Integer
    rand = Min + Int(Rnd() * (Max + 1))
End Function