我已经随机化了一个数组,因此每次播放测验时都会以不同的顺序显示问题,但如果问题无法重复,我会更喜欢它。
这是我的数组的设置方式:
Function loadQuestions()
Questions(0).Question = "Which of these words are an adjective?"
Questions(0).option1 = "Dog"
Questions(0).option2 = "Beautiful"
Questions(0).option3 = "Steven"
Questions(0).option4 = "Bird"
Questions(0).Answer = "B"
Questions(1).Question = "What's the adjective in this sentence:" & vbCrLf & "'Kelly handled the breakable glasses very carefully'"
Questions(1).option1 = "Kelly"
Questions(1).option2 = "Handled"
Questions(1).option3 = "Carefully"
Questions(1).option4 = "Breakable"
Questions(1).Answer = "D"
...
这是在测验开始时调用问题的函数。
Function GetQuestion(ByVal intQuestion As Integer)
tmrOne.Start()
If questionNumber < 11 Then
lblQuestionNumber.Text = "Question" & " " & questionNumber
Dim questionChosen As Integer
questionChosen = random.Next(25)
lblQuestion.Text = Questions(questionChosen).Question
btnAnswerA.Text = Questions(questionChosen).option1
btnAnswerB.Text = Questions(questionChosen).option2
btnAnswerC.Text = Questions(questionChosen).option3
btnAnswerD.Text = Questions(questionChosen).option4
strAnswer = Questions(questionChosen).Answer
questionNumber = questionNumber + 1
btnAnswerA.BackColor = Color.White
btnAnswerB.BackColor = Color.White
btnAnswerC.BackColor = Color.White
btnAnswerD.BackColor = Color.White
btnAnswerA.Enabled = True
btnAnswerB.Enabled = True
btnAnswerC.Enabled = True
btnAnswerD.Enabled = True
Return intQuestion
Else
MsgBox("You have finished")
End
End If
End Function
我试图在互联网上找到一些东西来帮助解决这个问题,但由于我是新手,所以没有成功或理解它。我找到了 ArrayList.RemoveAt 但不确定这是与我的数组一起使用的正确语法吗?
那么,如何阻止我的数组重复一个已经被问过的问题呢?我是否将它们放入另一个数组中?
任何帮助是极大的赞赏!