Hi I just started using VB 2008 and I am working with random number.
I got the code below from this site.
Dim random as New Random
dim num as integer
num=random.next(1,21)
My question is...How can I get out the duplicates numbers and replace them with the correct number?
Please help .
3 replies to this topic
#1
Posted 28 September 2011 - 04:58 PM
|
|
|
#2
Posted 28 September 2011 - 06:09 PM
You'll have to clarify. One of the properties of random numbers is that, given a long enough sequence, you should expect to get duplicates. Given that, what are you trying to do? What is a "correct number"?
#3
Posted 29 September 2011 - 07:45 AM
I think he means not having duplicates.. You must understand that as you go down the line, it will become increasingly difficult for the program to find a number that isn't used. You could probably use a For Each statement, but without any actual knowledge of how far into your code you are, we have no way of helping you.
#4
Posted 29 September 2011 - 10:55 AM
I figured as much. Usually, I'll do something like use an array or list to store the numbers I want to scramble, and reduce the range of random numbers by one while removing the selected item from the list.
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users


Sign In
Create Account

Back to top









