Re: Randomize question
- From: "Larry Serflaten" <serflaten@xxxxxxxxxxxxxx>
- Date: Fri, 28 Apr 2006 18:53:39 -0500
"Billy B" <BillyB@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote
I have the following code developed and it works fine. The number 125 in line
12 is the index number in the table. I have a two column Access table with
the week number and a word associated with that number. There are 25 words
per week and I want to randomly generate 25 words from the first five weeks
using the week numbers 1, 2, 3, 4 and 5. Instead of using the index number I
want to use the week numbers in the randomize statement.
I am in instructor and this is the last thing I need to figure out to make
the testing program work. Thank you.
It is not entirely clear what you want to happen. About the best I can gather
(from your words and code) is that you want 5 lists of 25 words from your
database of 125 words.
After a bit of thought, it may be you want to use words 1-25 for week one,
and 26-50 for week two, etc but still generate randomized lists. If that is
the case, you simply have to pick 1 number from 25 and add it to the
lower index value that is dependant on the current week (1, 26, 51, 76 ...)
But first, be aware, that Randomize is not a shake command as you
would think of shaking the dice, it is a seeding process which you should
do only once (at the start of your application).
Now for a bit of modification:
If WeekNumber < 1 or WeekNumber > 5 Then Err.Raise 5 <<< added
Private Sub GetWords(ByVal WeekNumber As Long)
Set rsTest = New clsRecSet
rsTest.rsSpell.Open strSQL
Dim intNum As Integer
Dim intRand As Integer
Dim intN As Integer
rsTest.rsSpell.MoveFirst
For intNum = 0 To 24
'Need to randomize using numbers 1,2,3,4,5 <<< Randomize removed
intRand = Int(25 * Rnd) + (WeekNumber * 25 - 24) <<< changed
rsTest.rsSpell.Move intRand, adBookmarkFirst
If rsTest.rsSpell.Fields(2).Value = False Then
txtCorrAns(intNum) = rsTest.rsSpell.Fields(1)
rsTest.rsSpell.Fields(2).Value = True
Else
GoTo Here
End If
Next
End Sub
.
- Follow-Ups:
- Re: Randomize question
- From: Larry Serflaten
- Re: Randomize question
- Prev by Date: Re: How to upload a file...
- Next by Date: Re: How to upload a file...
- Previous by thread: How to upload a file...
- Next by thread: Re: Randomize question
- Index(es):
Relevant Pages
|