Results 1 to 6 of 6
  1. #1
    New Lounger
    Join Date
    Feb 2003
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Random Numbers (VB6)

    Hi,

    Is there a way to randomly picking records from a table. I've tried using RND() but it seems the random sequence is repeated everytime the program is executed.
    I need something that is truly "random". Thanks.


    chl88

  2. #2
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Random Numbers (VB6)

    Look at the help for Randomize

    StuartR
    <font face="Georgia">
    <big>Randomize Statement</big>

    Initializes the random-number generator.

    Syntax

    Randomize [number]

    The optional number argument is a Variant or any valid numeric expression.

    Remarks

    Randomize uses number to initialize the Rnd function's random-number generator, giving it a new seed value. If you omit number, the value returned by the system timer is used as the new seed value.

    If Randomize is not used, the Rnd function (with no arguments) uses the same number as a seed the first time it is called, and thereafter uses the last generated number as a seed value.

    Note To repeat sequences of random numbers, call Rnd with a negative argument immediately before using Randomize with a numeric argument. Using Randomize with the same value for number does not repeat the previous sequence.
    </font face=georgia>

  3. #3
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Random Numbers (VB6)

    I don't suppose you have a little budget to play with? I do a little bit of legal work with a company that has a circuit board designed to generate truly random distributions (see product information for Random Master). Never tried it myself.

  4. #4
    Gold Lounger
    Join Date
    Dec 2000
    Location
    New Hampshire, USA
    Posts
    3,386
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Random Numbers (VB6)

    Who has verified that the numbers are truly random?

    The random number generators provided with most products do not really generate true random sequences.

    If the properties of the random number generated by VB are acceptable for your app, then you can include Randomize and select a different seed each time the program runs.

    If you want a better random number generator, ask the folkes in the, e.g., newsgroups comp.programming and sci.math.num-analysys.

  5. #5
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Random Numbers (VB6)

    > Who has verified that the numbers are truly random?

    That's a trick question: it's not possible to verify true randomness. <img src=/S/clever.gif border=0 alt=clever width=15 height=15>

  6. #6
    Gold Lounger
    Join Date
    Dec 2000
    Location
    New Hampshire, USA
    Posts
    3,386
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Random Numbers (VB6)

    It is possible to analyze the distribution and its properties against the criteria specified in books such as Knuth's.

    There are ongoing discussions of such issues in comp.programming and sci.math.num-analysis.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •