Monday, March 26, 2012

Please Help - WEB Application

Hi Everyone,

I have a VB script (.aspx) project that needs to produce nine unique,
randomly generated numbers that uses all nine of the numbers. I will greatly
appreciate either a recommendation of where to look on the web for my
answer, or your direct response.

Thanks a 1,000,000 for your ideas.
ChuckChuck Insight wrote:
> Hi Everyone,
> I have a VB script (.aspx) project that needs to produce nine unique,
> randomly generated numbers that uses all nine of the numbers. I will greatly
> appreciate either a recommendation of where to look on the web for my
> answer, or your direct response.
> Thanks a 1,000,000 for your ideas.
> Chuck

If I understand correctly, you want to generate a nine-digit
"random" code that uses all of the digits in 123456789.
(what about "0"?)

What you can do is
1) start with "123456789"
2) generate two random numbers from 0 to 8 (inclusive)
3) exchange the digits at those positions
4) repeat steps 2) and 3) a dozen times.

To generate a random number, see the System.Random class
(create *one* instance, then repeatedly get random numbers
from that class)

To generate nine of these codes, use this repeatedly
but check if you already have this particular code. If
yes, discard this code and generate again.

--
Hans Kesting

0 comments:

Post a Comment