Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Generate same password in the same second
Message
From
11/11/2008 11:18:40
 
 
To
11/11/2008 11:07:59
Timothy Bryan
Sharpline Consultants
Conroe, Texas, United States
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:
01361103
Views:
12
>>Michel,
>>
>>I wonder
>>(1) Why do you still have loRnd around - it is non-static
>>(2) Why do you still use it ? ( lnNext = loRnd.Next(100) )
>>(3) Why the sleep() ? System.Threading.Thread.Sleep(3)
>>I do not think that sleeping between calls to loRnd.Next()) has any influence on the random value being returned
>>
>>
>>Just replace
>>Dim loRnd As Random = New Random
>>with
>>Static loRnd As Random = New Random
>>
>
>For VB would this be:
>
>Shared as opposed to static?
>
dunno very much about vb - but

It seems to me that Static applies to a variable whereas Shared applies to a field of a class

Static http://msdn.microsoft.com/en-us/library/z2cty7t8.aspx
Specifies that one or more declared local variables are to continue to exist and retain their latest values after termination of the procedure in which they are declared.

Normally, a local variable in a procedure ceases to exist as soon as the procedure stops. A static variable continues to exist and retains its most recent value. The next time your code calls the procedure, the variable is not reinitialized, and it still holds the latest value that you assigned to it. A static variable continues to exist for the lifetime of the class or module that it is defined in


Shared http://msdn.microsoft.com/en-us/library/zc2b427x.aspx
Specifies that one or more declared programming elements are associated with a class or structure at large, and not with a specific instance of the class or structure.

Sharing a member of a class or structure makes it available to every instance, rather than nonshared, where each instance keeps its own copy. This is useful, for example, if the value of a variable applies to the entire application. If you declare that variable to be Shared, then all instances access the same storage location, and if one instance changes the variable's value, all instances access the updated value.
Gregory
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform