VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



A good function that returns a random number within a range. Will not give the same number back-to-

by The Emporer (4 Submissions)
Category: String Manipulation
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Sun 15th September 2002
Date Added: Mon 8th February 2021
Rating: (1 Votes)

A good function that returns a random number within a range. Will not give the same number back-to-back, easy to use.

API Declarations



Visit my site to get tools that will help you with your projects.
(http://LostEmpire.s5.com)

Rate A good function that returns a random number within a range. Will not give the same number back-to-



Public Function Rand(Start As Integer, End1 As Integer) As Integer
 Static rndLastNum As Integer
 Randomize
Retry:
 Do
   n = Round(Rnd * End1): DoEvents
 Loop Until (n >= Start) And (n <= End1)
 If (n = rndLastNum) Then GoTo Retry
 rndLastNum = n
 Rand = n
End Function


Download this snippet    Add to My Saved Code

A good function that returns a random number within a range. Will not give the same number back-to- Comments

No comments have been posted about A good function that returns a random number within a range. Will not give the same number back-to-. Why not be the first to post a comment about A good function that returns a random number within a range. Will not give the same number back-to-.

Post your comment

Subject:
Message:
0/1000 characters