CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: Rnd function

  1. #1
    Join Date
    Aug 1999
    Location
    US, Florida
    Posts
    817

    Rnd function

    how to rendomize between selected numbers. Like if 1,4,8,3 were picked, how to randomize between those 4 numbers. I just can get it, but it should be easy.
    Thanks

    Programs and requests for them for FREE.
    http://falstok.fly.to

  2. #2
    Join Date
    May 2000
    Location
    Sacramento, CA
    Posts
    103

    Re: Rnd function

    I think what you are looking for is to put the "n" target numbers into an array. Say as elements 0,1,...(n-1). Then you take int(n*rnd).

    Something like:

    Dim List()
    Dim n as Integer
    Dim i as Integer
    n = GetAValueofN()
    for i = 0 to n - 1
    List(i) = GetAValueofList()
    next i
    Randomize
    ARandomSelection = List(n * Rnd)



    where the functions GetAValueofN and GeetAValueofList do what they say.



    Dave Straayer
    Varatouch, Inc.
    David H. Straayer

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

Featured