新手求帮助有关于loop的问题
一共7到题目,答案是True, True, False, False, True, False, True我做的界面是一个2个radio button 显示true or false 一个txtbox显示问题,一个next buton按一下next显示下一题。老师的要求是必须加一个loop去做,(我加了loop 但是程序就会出错)不知道现在那步加loop比较好。我没有用loop去做,程序做出来了,但是出了点小毛病,用户不按true or false只按next,出来结果答对3题。不知道怎么搞。求大神
程序代码:
Public Class Form1 Dim Questions() As String = {"1.The squeaky wheel gets the grease", "2.Cry and you cry alone", "3.Opposites attract", "4.Spare the rod and spoil the child", "5.Actions speak louder than words", "6.Familiarity breeds contempt", "7.Marry in haste, repent at leisure"} Dim ans() As Boolean = {True, True, False, False, True, False, True} Dim Total As Integer = 0 Dim currentQuestion As Integer = 0 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load ShowQuestion() End Sub Private Sub ShowQuestion() TextBox1.Text = Questions(currentQuestion) End Sub Private Sub ShowScore() Select Case True Case Total < 5 MessageBox.Show("you get " & CStr(Total) & " Right") MessageBox.Show("You might consider taking Psychology 101") Case Total = 5, Total = 6 MessageBox.Show("you get " & CStr(Total) & " Right") MessageBox.Show("Excellent") Case Total = 7 MessageBox.Show("you get " & CStr(Total) & " Right") MessageBox.Show("Perfect") End Select End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click If RadioButton1.Checked = ans(currentQuestion) Then Total += 1 End If If currentQuestion = Questions.Length - 1 Then ShowScore() Button1.Enabled = False RadioButton1.Enabled = False RadioButton2.Enabled = False Else currentQuestion += 1 ShowQuestion() End If End Sub End Class