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

Thread: random posts?

  1. #1
    Join Date
    Mar 1999
    Posts
    1

    random posts?



    I doing a program in visual basic,but I have some problem with Randomize.I wonder if someone know how to do if you have a database and want the program to pick random post from the database and show them in a text field when you push a button.

    Thanks for your time.

    Mario Gustavsson

  2. #2
    Join Date
    May 1999
    Posts
    45

    Re: random posts?



    Radomize and rnd function together generate psuedo-random number. It's between 0 & 1 .


    Check number of records in DB. say n,

    Int((n * Rnd) + 1) ' Generate random value between 1 and n.

    Now open recordset and do MoveNext for n-1 times. This may not be a appropriate for large number of records though.






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