Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Generate same password in the same second
Message
De
10/11/2008 02:16:13
 
 
À
10/11/2008 01:59:03
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Versions des environnements
Environment:
VB 8.0
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Divers
Thread ID:
01360833
Message ID:
01360837
Vues:
16
>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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform