Re: Random Numbers are NOT random !!!
From: Larry Serflaten (serflaten_at_usinternet.com)
Date: 09/29/04
- Next message: Phill. W: "Re: a question about client~"
- Previous message: Gerry O'Brien [MVP]: "Re: Monitoring Server performance from .NET"
- In reply to: mark4asp: "Random Numbers are NOT random !!!"
- Next in thread: Gerry O'Brien [MVP]: "Re: Random Numbers are NOT random !!!"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 29 Sep 2004 06:49:47 -0500
"mark4asp" <mark4asp#killspam#@ntlworld.com> wrote
>
> How can I get the function [ d() ] to return a different random number
> each time?
>
> Function d(ByVal high) As Integer
> Return New System.Random().Next(1, high+1)
> End Function
That random generator is just that, a generator. You need to
fire it up and pull out the random numbers. What you are doing
is starting up a whole lot of new generators. Since the generators
use the current time as their seed (when you provide no seed yourself)
and you are calling them all in a blink of an eye, they are all created
using the same seed.
What you need to do is to declare your generator at the module
level:
Private RandomGenerator As New Random
And use your routine to pull out the random numbers:
> Function d(ByVal high) As Integer
> Return RandomGenerator.Next(1, high+1)
> End Function
See if that helps
LFS
- Next message: Phill. W: "Re: a question about client~"
- Previous message: Gerry O'Brien [MVP]: "Re: Monitoring Server performance from .NET"
- In reply to: mark4asp: "Random Numbers are NOT random !!!"
- Next in thread: Gerry O'Brien [MVP]: "Re: Random Numbers are NOT random !!!"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|