Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

randomize

Status
Not open for further replies.

natosubsonic

Programmer
Sep 17, 2003
3
0
0
AU
this is my code so far. i am building a a trivia based game i wish to randomize the forms. the names of forms are frmq1,frmq2 etc. is there any other ways to do this and what do i need to change or put in to make this code work. it is the second part. thanks for help.

Dim i As Integer

Private Sub btnstart_Click()
If opthard.Value = True Then
frmhard.Show
frmchoose.Hide
ElseIf opteasy.Value = True Then
Randomize
For i = 0 To 9
frmq(i).Show
frmchoose.Hide
Next
End If
End Sub
 
You don't need the for/next loop - check out the Rnd function. If you set up:



FormNo=Int((upperbound - lowerbound + 1) * Rnd + lowerbound) 'taken from documentation
frmq(FormNo).show

where lower bound=0 and upper bound =9 then I think you'd be just about there.


 
i still not really understanding that. i only just starting so a little explaination to it would help a lot. thanks. and were am i meant to put that.
 
i still not really understanding that. i only just starting so a little explaination to it would help a lot. thanks. and were am i meant to put that.


Dim i As Integer

Private Sub btnstart_Click()
If opthard.Value = True Then
frmhard.Show
frmchoose.Hide
ElseIf opteasy.Value = True Then
Randomize
FormNo = Int((upperbound - lowerbound + 1) * Rnd + lowerbound) 'taken from documentation
frmq(FormNo).Show
End If
End Sub

frmq is coming up as compile error sub or function not defined
is that what you meant or is there more i got to do.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top