You could use an array to hold the previous questions displayed, and validate the new random number against the contents of that array before showing it?
It may make it run slower, but at least it will only show once.
Private intCounter As Integer
Private intQuestion As Integer 'This is the random number from your existing code
Private Sub NewQuestion()
'-- Your source code so far but when you go to display the new question,
'Call the CheckQuestion function to ensure the question is not in the array.
If CheckQuestion(intQuestion) = False Then
'-- Make the question frame visible
'-- Generate a new random number and check again
Private Function CheckQuestion(RandomNumber as Integer) as Boolean
'-- Check against an array using the counter to go through each 'cell' of the array
'and if the random number is not found, continue to the next one. Continue until end.
'if random number is not found, return true so the question can be displayed.
'-- If the random number is found then return false so a new number can be generated.
intQuestion is the question number that you created in your existing code - the random number. I've included it here just for the purpose of clarity.
Apologies about the lack of an array code... they're not my strong point so I daren't embarrass myself!! (I'm still learning), but the theory is there.
Hopefully someone a bit cleverer than me on VB will help me out :)
For Each ctrl As Control In Me.Controls("pnlMainPanel").Controls
If ctrl.GetType Is GetType(System.Windows.Forms.Panel) Then
For Each subCtrl As Control In ctrl.Controls
If subCtrl.GetType Is GetType(System.Windows.Forms.TextBox) Then
If subCtrl.GetType Is ...