Script Random Number
Last changed: dale@mcneel.com-204.177.179.144

.
DeveloperRhinoScript
SummaryHow to generate random numbers that fall within a specified range.

Sample Code

The following code sample demonstrates how to generate random numbers that fall within a specified range.

    Function RandomNumber(nMin, nMax)
      RandomNumber = Null
      If Not IsNumeric(nMin) Then Exit Function
      If Not IsNumeric(nMax) Then Exit Function
      If nMin >= nMax Then Exit Function
      Randomize
      RandomNumber = Int((nMax - nMin + 1) * Rnd + nMin)
    End Function