how to break repeating random
hi guys any one can help me out for this problem..
i create a fuction to generate all the question. also this fuction have a random how can i put a code to break the repeting random.. thanks
here my sample code
Code:
Public Function Generat1n()
Dim j As Integer
Open App.Path & "\Questions.mezz" For Input As #1
j = Int(Rnd * 12)
For i = 0 To j
Line Input #1, question
Next i
Label1.Caption = question
Close #1
End Function
what will i insert code and where i will put?
Re: how to break repeating random
Use the RANDOMIZE function just before the RND line
See some examples here ---> http://www.developerfusion.com/code/...andom-numbers/
Re: how to break repeating random
thanks i use it but the random still repeating
Re: how to break repeating random
Okay your been very vague....
"random still repeating" dies not help ... what we need to know is it :
#1).. Every time you run the program the questions repeat in the same order !!
#2).. The questions are random, but some of the question repeat every now and then...!!
solutions:
#1) randomize using the clock or ticker as a base number.
#2) Keep track of which questions have been asked and skip them if they 'pop up' again...
Re: how to break repeating random
If you only want each question to be asked once then one option would be to load the entire file into a listbox at the beginning (form_load)
Also put the call to Randomize in Form_Load
When you want to get a question use the rnd in the range of 0 to listcount-1 to get a question from the list and then remove that question from the list
This way you will get the questions asked in random order and will not get the same question twice