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:16:13
 
 
To
10/11/2008 01:59:03
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:
01360837
Views:
15
>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.
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform