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:
' You may freely distribute this file but please leave all comments, including this one, in it.
' @Author Stefan Thoolen <>

Option Explicit

' Generate a random integer
' Same syntax as the PHP function 'rand'
' See also:
' @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 <>
Public Function rand(Min As Integer, Max As Integer) As Integer
    rand = Min + Int(Rnd() * (Max + 1))
End Function