realbasic-nug
[Top] [All Lists]

Re: random seed generator?

To: REALbasic NUG <realbasic-nug at lists dot realsoftware dot com>
Subject: Re: random seed generator?
From: Michael <mdeh at comcast dot net>
Date: Wed, 29 Nov 2006 14:11:52 -0800
Delivered-to: listarchive at realsoftware dot com
Delivered-to: realbasic-nug at lists dot realsoftware dot com
References: <21238198-7650-4FF8-A2A5-2CC3FCC0128B at comcast dot net> <0B4C8C10-69ED-49C4-9A9E-D883B4418CA1 at tolisgroup dot com>
Hi Tim
I thought I was doing that...but will try again. Your code is what I am looking for.


Here is what I did:


  dim d As new date
  dim i,p as integer
  dim r As new Random
  r.Seed=d.TotalSeconds

  dim s As String

  for i = 0 to 63
    p=r.InRange(0,15)
    s=s+hex(p)
  next

  EditField1.text=s

But, if I look at the seed generated each time, it is always the same. (3.247654e+9). And if simply omit seeding the random, I get new numbers each time too!

MIchael.



On Nov 29, 2006, at 2:05 PM, Tim Jones wrote:

I use the current time's "totalseconds" value as it always provides a different starting point.

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>


<Prev in Thread] Current Thread [Next in Thread>