Random number within a range

This is a small ASP function that will return a random number between two numbers. It will takes two numbers (maximum & minimum) numbers and generate a random number within that range. It will geenrate a random number every time the function is called. Quite handy function for general purpose use where a random number is needed in ASP.

'*******************************************************
'*     MYCPLUS Sample Code - http://www.mycplus.com     *
'*                                                     *
'*   This code is made available as a service to our   *
'*      visitors and is provided strictly for the      *
'*               purpose of illustration.              *
'*                                                     *
'* Please direct all inquiries to saqib at mycplus.com *
'*******************************************************

'
'Function to Return a Random number with in a range
'

Public Function RandomNumber(MaxValue,MinValue )

  On Error Resume Next
  Randomize Timer
  RandomNumber = Int((MaxValue - MinValue + 1) * Rnd) + MinValue

End Function

Leave a Reply