Results 1 to 3 of 3

Thread: Random number

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Nov 2005
    Posts
    164

    Random number

    whats the best way to pick a random selection from a database table.

    using the ranomize () function there is a fault i heard ?

  2. #2
    No place like 127.0.0.1 eyeRmonkey's Avatar
    Join Date
    Jul 2005
    Location
    Blissful Oblivion
    Posts
    2,306

    Re: Random number

    Try searching before posting your question. You could have found the answer to this in the Visual Studio help files or online very easily.

    Randomize() is no longer necessary in Visual Basic .NET. The only fault with any random number generator is that it is not "truly random." For all intents and purposes it is, but a machine is incapable of developing a 100% random number because it is always based on an algorithm.

    Here is all you need to do to get a random number:
    VB Code:
    1. Dim r As New Random
    2. Dim MyInt As Integer = r.Next(1, 100)

    That will give you a random number between 1 and 99 (not 100). Just replace the min and max with what you need them to be.
    Visual Studio 2005 Professional Edition (.NET Framework 2.0)
    ~ VB .NET Links: Visual Basic 6 to .NET Function Equivalents (Thread) | Refactor! (White Paper) | Easy Control for Wizard Forms | Making A Proper UI For WinForms | Graphics & GDI+ Tutorial | Websites For Free Icons
    ~ QUOTE: Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. -Rich Cook

    ~ eyeRmonkey.com

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Nov 2005
    Posts
    164

    Re: Random number

    Thanks

Posting Permissions

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



Click Here to Expand Forum to Full Width