Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Generate same password in the same second
Message
From
10/11/2008 02:17:38
 
 
To
10/11/2008 02:16:13
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Environment versions
Environment:
VB 8.0
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01360833
Message ID:
01360838
Views:
54
>>The remarks in the doc
>>
>>However, because the clock has finite resolution, using the parameterless constructor to create different Random objects in close succession 
>>creates random number generators that produce identical sequences of random numbers.
>>
>>
>>I see two possibilities
>>(1) Use a constructor with a parameter - the syntax will be C# as I'm not familiar with vb
>>
>>var loRnd = new Random((int)DateTime.Now.Ticks);
>>
>>
>>(2) If that does not help - make loRnd a static field so that the next sequence will always be different
>>
>>
>>I'm in favour of (2)
>
>Method number one, as converted as this:
>
>
>Dim loRnd = New Random(CInt(DateTime.Now.Ticks)) 
>
>
>gives an arithmetic operation resulted in an overflow.

try
dim loRnd = new Random( DateTime.Now.Ticks.GetHashCode() );
Gregory
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform