•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the ASP.NET section within the Web Development category of DaniWeb, a massive community of 426,810 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 1,888 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ASP.NET advertiser: Lunarpages ASP Web Hosting
Views: 885 | Replies: 10 | Solved
![]() |
•
•
Join Date: Oct 2006
Location: somewhere in West-Africa
Posts: 202
Reputation:
Rep Power: 3
Solved Threads: 6
Use the Random Class.
Here I am filling an array with random numbers. Note that I have used the goto statement so ensure that unique numbers are inserted into the array. (Avoiding Duplicates)
asp.net Syntax (Toggle Plain Text)
Dim arbit As New Random Randomize() X: For i = 0 To a.GetUpperBound(0) t = arbit.Next(1, 10) ' Generate between the numbers 1 and 10 If Array.IndexOf(a, t) = -1 Then a(i) = t Else GoTo X End If Next
Here I am filling an array with random numbers. Note that I have used the goto statement so ensure that unique numbers are inserted into the array. (Avoiding Duplicates)
My blog on .NET- http://dotnet.tekyt.info
•
•
Join Date: Oct 2006
Location: somewhere in West-Africa
Posts: 202
Reputation:
Rep Power: 3
Solved Threads: 6
•
•
•
•
tuse,
thanks for your reply. Yes that is a good idea, but if i fill the first line with 16 integers (aided by an array) I would want the next group of 16 to be unique as a group. So if I generate 1000 of such group of 16 integers no group would apear twice. I hope the challenge is clearer.
Thanks
Do you mean the uniqueness of the numbers should be restricted to a group of 16 or do you want 16 x 40 unique numbers
--------------------
Yeah I got what you are trying to say.
Last edited by tuse : Jul 25th, 2008 at 1:06 pm. Reason: Eureka!
My blog on .NET- http://dotnet.tekyt.info
Can you tell me the range in which you need these integers?
I have something in mind which depends upon this.
I have something in mind which depends upon this.
My blog on .NET- http://dotnet.tekyt.info
•
•
Join Date: Oct 2006
Location: somewhere in West-Africa
Posts: 202
Reputation:
Rep Power: 3
Solved Threads: 6
Yes,
the integers naturally would be 0 to 9 for the groups.
i mean something like this
get it?
peace
the integers naturally would be 0 to 9 for the groups.
i mean something like this
1. 8937474633290944 2. 8464595950698568 3. 0734736478237473 ... 40 9689896859895596
peace
Try this-
Just generate 16 x 40 numbers random numbers using the code. If you want it in the range as said, find the remainder of the generated random numbers on division by 10. Then split this one dimensional array into the matrix you need.
------
Hopefully you will get as you need.
But by no means is this the best way to go. There might (must) be a better way.
------
Are you using this for an online test application?
Just generate 16 x 40 numbers random numbers using the code. If you want it in the range as said, find the remainder of the generated random numbers on division by 10. Then split this one dimensional array into the matrix you need.
------
Hopefully you will get as you need.
But by no means is this the best way to go. There might (must) be a better way.
------
Are you using this for an online test application?
Last edited by tuse : Jul 25th, 2008 at 1:43 pm. Reason: Saw the previous post
My blog on .NET- http://dotnet.tekyt.info
•
•
Join Date: Oct 2006
Location: somewhere in West-Africa
Posts: 202
Reputation:
Rep Power: 3
Solved Threads: 6
No no i am not using this for an e-testing software.
Thanks all the same tuse. You are a great guy
U know talking about another way, I had this idea of generating guids then picking out 16 characters and then changing the alphabets to their numeric equivalents. Then save the results in a database table with the number being the primary key trusting the database to throw out duplicates if any.
Now how's that
what's your take?
Thanks all the same tuse. You are a great guy
U know talking about another way, I had this idea of generating guids then picking out 16 characters and then changing the alphabets to their numeric equivalents. Then save the results in a database table with the number being the primary key trusting the database to throw out duplicates if any.
Now how's that
what's your take?
•
•
•
•
Try this-
Just generate 16 x 40 numbers random numbers using the code. If you want it in the range as said, find the remainder of the generated random numbers on division by 10. Then split this one dimensional array into the matrix you need.
------
Hopefully you will get as you need.
But by no means is this the best way to go. There might (must) be a better way.
------
Are you using this for an online test application?
Last edited by jamello : Jul 25th, 2008 at 2:22 pm.
Since you want to create 40 unique groups where within a group a number may repeat.
Create a array of string and every time a group is created store that as a string.
Just compare the contents of the string with the newly created group. if they are the same abandon it else enter it as the 'n+1'th element of the array.
Thus you will get 40 groups which are unique.
Create a array of string and every time a group is created store that as a string.
Just compare the contents of the string with the newly created group. if they are the same abandon it else enter it as the 'n+1'th element of the array.
Thus you will get 40 groups which are unique.
umm.. what prasu says is correct.
Its just that sometimes you may have to do a lot of comparisons.
Its just that sometimes you may have to do a lot of comparisons.
My blog on .NET- http://dotnet.tekyt.info
![]() |
•
•
•
•
•
•
•
•
DaniWeb ASP.NET Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Similar Threads
- program to generate random numbers for a given range (C++)
- how to use generate random numbers (Visual Basic 4 / 5 / 6)
- Program will not generate random numbers (C++)
- need help, need to generate 10 random numbers, such that their sum is less than 1 (C)
- Trying to find a better way to generate random numbers in Dev Pascal (Pascal and Delphi)
- generate random question (C)
- random numbers all different??? (C++)
Other Threads in the ASP.NET Forum
- Previous Thread: Online Test Creation
- Next Thread: Please help me asap.


Linear Mode