CodeItBetter Programming Another VB Programming Blog

How to generate a random number, in between two given values.

Posted on September 5, 2011
1
2
3
4
5
6
7
8
9
'Math - How to generate a random number, in between two given values.
'S = smallest number that it could return
'L = largest number that it could return

Option Explicit
 
Private Function Random(ByVal S As Long, ByVal L As Long) As Long
    Random = CLng(Rnd * (L - S + 1)) + S)
End Function
Filed under: Math Leave a comment
Comments (0) Trackbacks (0)

No comments yet.


Leave a comment


 

No trackbacks yet.