不确定为什么我的测验没有被宣布错误?(见粗体测验)请帮我解决这个问题。我试图以几种不同的方式宣布测验,但我卡住了。这个测验将在问题和答案部分中进行更多修改,因为我想将此模板用作圣经学习工具。谢谢你的帮助。
Option Strict On
Public Class Form2
Dim TestAboutMe As New Quiz3x
Friend WithEvents QuizStart, AnswerSubmit As New System.Windows.Forms.Button
Friend WithEvents RadioButton1, RadioButton2, RadioButton3, RadioButton4 As New System.Windows.Forms.RadioButton
Friend WithEvents Label1 As New System.Windows.Forms.Label
Sub ResetQuiz()
TestAboutMe.Clear()
TestAboutMe.AddQuestion(Quiz.Question("What is 2 x 1 ?", {"2", "3", "5", "7"}.ToList, "2"))
TestAboutMe.AddQuestion(Quiz.Question("What is 2 x 2 ?", {"3", "5", "4", "7"}.ToList, "4"))
TestAboutMe.AddQuestion(Quiz.Question("What is 2 x 3 ?", {"6", "99", "7", "1"}.ToList, "6"))
TestAboutMe.AddQuestion(Quiz.Question("What is 2 x 4 ?", {"8", "0", "9", "2"}.ToList, "8"))
TestAboutMe.AddQuestion(Quiz.Question("What is 2 x 5 ?", {"12", "10", "5", "7"}.ToList, "10"))
TestAboutMe.AddQuestion(Quiz.Question("What is 2 x 6 ?", {"6", "66", "666", "12"}.ToList, "12"))
TestAboutMe.AddQuestion(Quiz.Question("What is 2 x 7 ?", {"13", "15", "14", "55"}.ToList, "14"))
TestAboutMe.AddQuestion(Quiz.Question("What is 2 x 8 ?", {"15", "14", "17", "16"}.ToList, "16"))
TestAboutMe.AddQuestion(Quiz.Question("What is 2 x 9 ?", {"17", "18", "12", "33"}.ToList, "18"))
TestAboutMe.AddQuestion(Quiz.Question("What is 2 x 10 ?", {"20", "18", "19", "22"}.ToList, "20"))
TestAboutMe.AddQuestion(Quiz.Question("What is 2 x 11 ?", {"23", "24", "22", "32"}.ToList, "22"))
TestAboutMe.AddQuestion(Quiz.Question("What is 2 x 12 ?", {"23", "24", "25", "12"}.ToList, "24"))
RadioButton1.Checked = False : RadioButton2.Checked = False
RadioButton3.Checked = False : RadioButton4.Checked = False
RadioButton1.Visible = True : RadioButton2.Visible = True
RadioButton3.Visible = True : RadioButton4.Visible = True
End Sub
End Class
Public Class Quiz3x
Private Property _Questions As New List(Of Question)
Private Index As Integer = 0
Private _CurrentQuestion As Question
Private Property _CorrectAnswers As Integer = 0
Private Property _TestComplete As Boolean = False
Public ReadOnly Property TestComplete As Boolean
Get
Return _TestComplete
End Get
End Property
Public ReadOnly Property CurrentQuestion As Question
Get
Return _CurrentQuestion
End Get
End Property
Public ReadOnly Property TotalQuestions As Integer
Get
Return _Questions.Count
End Get
End Property
Public ReadOnly Property CorrectAnswers As Integer
Get
Return _CorrectAnswers
End Get
End Property
Public ReadOnly Property Questions As List(Of Question)
Get
Return _Questions
End Get
End Property
Public Sub NextQuestion()
Dim TmpIndex As Integer = Index
Index = Index + 1
If TmpIndex > Questions.Count - 1 Then
_TestComplete = True
Exit Sub
End If
_CurrentQuestion = Questions(TmpIndex)
End Sub
Public Sub AddQuestion(ByVal Question As Question)
_Questions.Add(Question)
End Sub
Public Sub GradeQuestion(ChosenAnswer As String)
If ChosenAnswer = CurrentQuestion.CorrectAnswer Then
_CorrectAnswers = _CorrectAnswers + 1
End If
End Sub
Public Sub Clear()
_Questions.Clear()
Index = 0
_CorrectAnswers = 0
_TestComplete = False
End Sub
Class Question
Private _Question As String
Private _Choices As New List(Of String)
Private _CorrectAnswer As String
Public ReadOnly Property Question As String
Get
Return _Question
End Get
End Property
Public ReadOnly Property Choices As List(Of String)
Get
Return _Choices
End Get
End Property
Public ReadOnly Property CorrectAnswer As String
Get
Return _CorrectAnswer
End Get
End Property
Sub New(Question As String, Choices As List(Of String), CorrectAnswer As String)
_Question = Question
_Choices = Choices
_CorrectAnswer = CorrectAnswer
End Sub
End Class
End Class
这是表格2 表单1有一个msgbox按钮
答案 0 :(得分:1)
CHANGE: TestAboutMe.AddQuestion(Quiz.Question(........ 到
TestAboutMe.AddQuestion(新Quiz3x.Question(.................
答案 1 :(得分:0)
在Sub ResetQuiz()中更改每个
TestAboutMe.AddQuestion(Quiz.Question(...
到
TestAboutMe.AddQuestion(New Quiz.Question(...