|
|
Home » Visual Basic » Article
VB - Generate an Array of Unique Random Numbers
|
| Article by: | Brian Gillham (8/26/2002) |
|
| Sponsored by: | FindMyHosting - Web Hosting Search |
| Summary: | This function will generate an ARRAY of TRULY random numbers. |
|
| Viewed: 84175 times |
Rating (32 votes): |
|
4.3 out of 5 |
|
|
|
VB - Generate an Array of Unique Random Numbers
This function will generate an ARRAY of TRULY random numbers. By default they are unique but this is a parameter which can be parsed. Useful for generating Lottery Numbers etc. I tried searching the net but could not find anything that could do this with the simplicity of this function. See comments within code for full explanation and sample.
|
|
View highlighted Comments
User Comments on 'VB - Generate an Array of Unique Random Numbers'
|
|
|
Posted by :
Archive Import (Joan Dav) at 01:41 on Thursday, November 21, 2002
|
This is great random numbers for vb but i need your help for a problem of mine...
Can you please tell me how to do coding for selecting random name using visual basic. Kind of Lucky Draw game, where a person name is randomly selected.
| |
Posted by :
Archive Import (Reg) at 05:56 on Monday, December 09, 2002
|
Excellent saved me lots of time typeing boring code....
| |
|
|
Posted by :
Archive Import (Paul) at 10:24 on Thursday, February 27, 2003
|
Unfortunately, as pointed out by Bob, there are no truly random numbers - they are derived by calculation, but the code works well.
| |
|
|
|
|
Posted by :
Archive Import (simon) at 12:13 on Wednesday, March 05, 2003
|
Program works well. Bob or Paul I was wondering if you could explain how the numbers are derived by calculation in the code.
| |
Posted by :
Archive Import (josh) at 20:35 on Thursday, May 01, 2003
|
i belive that the random number generator in vb uses time and and a certian calculation using that time to get random numbers.
P.S. don't quote me on this
| |
Posted by :
Archive Import (arunb) at 09:03 on Thursday, June 05, 2003
|
Dear Brian Gillham,
Suber Code, which iam trying to loace from the past. Its working gr8.
| |
Posted by :
Archive Import (Deetch) at 04:32 on Thursday, June 26, 2003
|
I believe the computer time is used to pick a starting point in a large table of random numbers which is as old as BASIC (maybe even older). If you do not "randomly" change the starting point in the RND-table you'll get the same result every time. I noticed this when I was programming dice for a RISK-game a few years ago.
| |
Posted by :
Archive Import (Crux) at 14:29 on Saturday, July 05, 2003
|
I thought vb used a formula to derive its random numbers, not selecting them from a table. I think that the formula includes the seed and the number of random numbers already generated. If you notice when you say randomize 1 you get a low number, as the seed increases, so does the first "random" number.
| |
|
|
Posted by :
Archive Import (hani) at 17:20 on Sunday, July 13, 2003
|
can you send the program of visual basic that have a random form
what is the code that random forms because i,m have a create games but the forms in this game is random
plz send and thanks with the web
hani zein - saida-south lebanon
bye
| |
Posted by :
Archive Import (Debabrata Das) at 05:13 on Thursday, September 04, 2003
|
I appreciate the codes, works fine.
I saved a lot of time.
Thanks a lot
| |
Posted by :
suresh at 08:44 on Monday, September 29, 2003
|
I needed help in a writing code for generating 6 random numbers 1 to 49 in a label array, when i click the command button. the generated random numbers should be unique, should not repeat. should be dispalyed in a ascending order . can you help me please?
suresh
| |
Posted by :
webit at 10:15 on Monday, November 01, 2004
|
I needed help in a writing code similar to the one suresh needs for generating random numbers in a label array, when i click the command button. the generated random numbers should be unique, should not repeat. should be dispalyed in a ascending order . can you help me please?
| |
|
To post comments you need to become a member. If you are already a member, please log in .
| RELATED ARTICLES |
Generate License Keys (such as CD keys on Microsoft software) by Brian Gillham
This class allows you to generate license keys, such as the CD keys on the case of most Microsoft software |
 |
Visual Basic Read and Modify the Registry by Kenneth Ives
Perform the four basic functions to the Windows registry. Add, change, delete, and query. Allows you to to read registry values, and modify both keys and values.
|
 |
Communicating with the Database (Using ADO) by Chaudhary Pradeep K. Roy
Using ADO to get connected with the database. |
 |
Generate an Array of Unique Random Numbers by Brian Gillham
This function will generate an ARRAY of TRULY random numbers. |
 |
Beginning Resource Files in Visual Basic by Kenneth Ives
Have you ever wanted to use graphics, such as icons, bitmaps, cursors, and AVI files? How about sound or even message box text? This can be an enormous amount of overhead. These are all examples of more files to keep track of when you distribute an application, DLL, or OCX. Lets find out how resource files can help.... |
 |
Visual Basic Compact/Repair Access Database Utility by Kenneth Ives
This utility will compact and repair the access database you select. It is actually more convenient to use this utility than do the same task with Access, because you don't have to save the database with a different name and then delete the old database when you are done: here, a temporary copy of the database is automatically created and deleted. |
 |
Creating a watermark in Excel with VBA by Kenneth Ives
Adding a watermark to an Excel spreadsheet using VBA. |
 |
Generate your own Random Numbers by Thaha Hussain
This simple program generates random numbers using the basic mathematical methods. |
 |
Change Cursor to Hour Glass by Brian Gillham
A simple script to change the cursor to an hour glass. |
 |
Analog Clock by Thaha Hussain
This program demonstrates Thaha Hussain's Clock Work Formula to paint an Analogue Clock. |
 |
| |