Hi;
I need help woth random number generation. I am developing a game show which has more than 100 questions and for each question there are 4 options. I am using a random function which ranomizes the value of t (row value of database). But the problem is that I can't stop the duplication, I have used the standard rndm function with lower and upper bound values and have also used randomize funtion for generating a different question every time game show starts.

t = Int((50 - 1) * Rnd() + 1)

t= 50 in this case, i.e. 50 rows have data and I want to randomize this data such that 50 questions are answered but with random order of questions. Below is the code where image and text file are imported from access db.

Dim adp As New OleDbDataAdapter("select * from tb1 where [QID]=" + t.ToString(), con)
                Dim ds As New DataSet
                adp.Fill(ds)
                Dim dt As DataTable
                dt = ds.Tables(0)
                qbox.Text = dt.Rows(0).Item(1)
                PictureBox1.ImageLocation = dt.Rows(0).Item(2)
                PictureBox2.ImageLocation = dt.Rows(0).Item(3)
                PictureBox3.ImageLocation = dt.Rows(0).Item(4)
                PictureBox4.ImageLocation = dt.Rows(0).Item(5)
                con.Close()

Can I use a counter with a value set to 50 and then rduce the count by 1 to get exact 50 questions.
Any help would be appreciated.

I donot about counter .But i created a program like this , but i used a different way ..
When i created database i just added one more field in the table , named " CHECKER " and then
When the application starts then all the values in that field will become 0 [ using the loop ]
Then i used random function.When one question appear then the corresponding field " CHECKER " will become 1.
But next time when the random function calls then it will check this field , If it is 1 then it will go for another data else if it is 0 then the question will appear.

" But in case of too many questions in database this will be totally a bad idea. , i don't know ! "
Good luck !

Hey something is not right here my post is just DUPLICATED !
--------------------------------------------------

I have tried this.. but not successful. I do a compare before the function is called with the current value of t and a temp vlaue. Problem is that I have to define t as Public. If I use a counter within the function, it will loop again and agian within the function. I need a counter such that when I click the right answer choice, it decreases by 1 and so on until reaches 0 and then terminates.
One more thing, the game is timed, On the click of option, a timer starts and runs for 20 seconds. 
Would it be better to run the counter with every click of timer

Create a List(Of Integer) with values 1-100 and get a random number 0-List.Count-1, and when you pull out the number, remove it from the list. This way you will be accessing a random index of the list and after you consume the question remove it from the list.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.