Hi,
Is there an option/ or a formula to generate random numbers without duplication...Currently i'm not storing the random generated numbers in the database.
Please help me..its quite urgent
Hi,
Is there an option/ or a formula to generate random numbers without duplication...Currently i'm not storing the random generated numbers in the database.
Please help me..its quite urgent
Jump to PostHi,
Is there an option/ or a formula to generate random numbers without duplication...Currently i'm not storing the random generated numbers in the database.
Please help me..its quite urgentYou can use the below function to return a random number
Public Function GetRandomNumber(Upper As Integer, Lower As Integer) As …
Use the Rnd function (see VB's help), with randomize. Use an array to hold the values, and use a sorting routine or just a simple For Loop structure to make sure a duplicate number is not generated.
Good Luck
Try using the RND([number]) in a loop to generate the nos. randomly....
TC
Hi,
Is there an option/ or a formula to generate random numbers without duplication...Currently i'm not storing the random generated numbers in the database.
Please help me..its quite urgent
Hi,
Is there an option/ or a formula to generate random numbers without duplication...Currently i'm not storing the random generated numbers in the database.
Please help me..its quite urgent
You can use the below function to return a random number
Public Function GetRandomNumber(Upper As Integer, Lower As Integer) As Integer
'Generates a Random Number BETWEEN the LOWER and UPPER values
Randomize
GetRandomNumber = Int((Upper - Lower + 1) * Rnd + Lower)
End Function
For preventing duplication you need to write seperate code to check each random number returned by this function against your the list of already used numbers.
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.