Option Explicit On
Option Strict On
Public Class SurveyForm
Structure Question
Dim QuestionString As String
End Structure
Structure Answer
Dim AnswerInteger As Integer
End Structure
Private QuestionGroup(9) As Question
Private AnswerGroup(9, 4) As Answer
Private indexinteger As Integer = 0
Private Sub QuestionGroupBox_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles QuestionGroupBox.Enter
End Sub
Private Sub ExitButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitButton.Click
Me.Close()
End Sub
Private Sub SurveyForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim always As Integer
Dim never As Integer
Dim seldom As Integer
Dim sometimes As Integer
Dim usually As Integer
If AlwaysRadioButton.Checked = True Then always += 1
If NeverRadioButton.Checked = True Then never += 1
If SeldomRadioButton.Checked = True Then seldom += 1
If SometimesRadioButton.Checked = True Then sometimes += 1
If UsuallyRadioButton.Checked = True Then usually += 1
AlwaysRadioButton.Checked = False
NeverRadioButton.Checked = False
SeldomRadioButton.Checked = False
SometimesRadioButton.Checked = False
UsuallyRadioButton.Checked = False
QuestionGroup(0).QuestionString = "Question 1: Do you read the textbook chapter after class"
QuestionGroup(1).QuestionString = "Question 2: Do you complete the homework when it is assigned"
QuestionGroup(2).QuestionString = "Question 3: Do attend class regularly"
QuestionGroup(3).QuestionString = "Question 4: Do you participate in class discussions"
QuestionGroup(4).QuestionString = "Question 5: Do you participate in a study group"
QuestionGroup(5).QuestionString = "Question 6: Do you answer questions in the textbook"
QuestionGroup(6).QuestionString = "Question 7: Do you practice with the hands on excersice"
QuestionGroup(7).QuestionString = "Question 8: Do you try little projects to test all new topics"
QuestionGroup(8).QuestionString = "Question 9: Do you ask questions when you are unsure about a topic?"
QuestionGroup(9).QuestionString = "Question 10: Do you use the online help to learn more about each feature?"
AnswerGroup(0, 0).AnswerInteger = always
End Sub
Private Sub BeginSurveyButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BeginSurveyButton.Click
QuestionLabel.Text = QuestionGroup(indexinteger).QuestionString
If indexinteger < QuestionGroup.Length Then
indexinteger += 1
If indexinteger = 10 Then
QuestionLabel.Text = "Thank you for completing the survey"
End If
End If
BeginSurveyButton.Text = "Next Question"
If indexinteger = 10 Then
BeginSurveyButton.Enabled = False
End If
If AlwaysRadioButton.Checked = False Then
If NeverRadioButton.Checked = False Then
If SeldomRadioButton.Checked = False Then
If SometimesRadioButton.Checked = False Then
If UsuallyRadioButton.Checked = False Then
MessageBox.Show("Please select an answer", "Invalid Answer", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
indexinteger -= 1
End If
End If
End If
End If
End If
PrintButton.Enabled = False
NextButton.Enabled = False
If indexinteger = 10 Then
PrintButton.Enabled = True
NextButton.Enabled = True
End If
End Sub
Private Sub AlwaysRadioButton_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AlwaysRadioButton.CheckedChanged, NeverRadioButton.CheckedChanged, SeldomRadioButton.CheckedChanged, SometimesRadioButton.CheckedChanged, UsuallyRadioButton.CheckedChanged
End Sub
Private Sub NextButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NextButton.Click
NextButton.Enabled = False
PrintButton.Enabled = False
BeginSurveyButton.Enabled = True
QuestionLabel.Text = QuestionGroup(0).QuestionString
NeverRadioButton.Checked = False
AlwaysRadioButton.Checked = False
SeldomRadioButton.Checked = False
SometimesRadioButton.Checked = False
UsuallyRadioButton.Checked = False
End Sub
End Class
好的,这是我的代码,任务是创建一个项目,用户将在其中完成 10 个问题的调查。创建一个表单,其中包含带有以下每个问题的标签和一组带有以下响应的每个问题的单选按钮:总是、通常、有时、很少,并且永远不要使用二维数组来累积每个问题的每个响应的数量一个菜单或按钮选项,将在打印机上打印项目分析,显示问题编号和每个响应的计数我试图打印多个调查的答案总和我想知道我该怎么做