Random Record Selection

Results 1 to 2 of 2

Thread: Random Record Selection

  1. #1
    Join Date
    Dec 1969

    Default Random Record Selection

    I wiould like to select a record randomly from a set of records (record set). Like a lottery draw. Is there any method to select one record randomly from record set

  2. #2
    Join Date
    Dec 1969

    Default RE: Random Record Selection

    Use vbscript randomize and rnd to generate a random number.<BR><BR>1.) get a record count from your recordset into something like intRsCount.<BR><BR>2.) put "randomize" w/o quotes in your asp<BR><BR>3.) call a function like this. intGoToRec = GetRandomNumber(intRsCount)<BR>Function GetRandomNumber(intSize)<BR> intRecord = Int((intSize * Rnd) + 1) <BR> GetRandomNumber = intRecord<BR>End Function<BR><BR>4.) now use the move to that number and write out that record.<BR><BR>that was quickly made up, it should work, I am sure you can create something a little cleaner, but that will work as it.<BR><BR>Hope that helps<BR>

Posting Permissions

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