| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 526 人关注过本帖
标题:新手求帮助有关于loop的问题
只看楼主 加入收藏
baobmw
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2014-2-16
收藏
 问题点数:0 回复次数:0 
新手求帮助有关于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

搜索更多相关主题的帖子: button False false 用户 
2014-02-16 06:59
快速回复:新手求帮助有关于loop的问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.046691 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved