📄 frmanswer.vb
字号:
Me._OptChoice_4.TextAlign = System.Drawing.ContentAlignment.MiddleLeft
Me._OptChoice_4.Text = "Option4"
Me._OptChoice_4.Size = New System.Drawing.Size(233, 17)
Me._OptChoice_4.Location = New System.Drawing.Point(240, 64)
Me._OptChoice_4.TabIndex = 10
Me._OptChoice_4.CheckAlign = System.Drawing.ContentAlignment.MiddleLeft
Me._OptChoice_4.BackColor = System.Drawing.SystemColors.Control
Me._OptChoice_4.CausesValidation = True
Me._OptChoice_4.Enabled = True
Me._OptChoice_4.ForeColor = System.Drawing.SystemColors.ControlText
Me._OptChoice_4.Cursor = System.Windows.Forms.Cursors.Default
Me._OptChoice_4.RightToLeft = System.Windows.Forms.RightToLeft.No
Me._OptChoice_4.Appearance = System.Windows.Forms.Appearance.Normal
Me._OptChoice_4.TabStop = True
Me._OptChoice_4.Checked = False
Me._OptChoice_4.Visible = True
Me._OptChoice_4.Name = "_OptChoice_4"
Me._OptChoice_3.TextAlign = System.Drawing.ContentAlignment.MiddleLeft
Me._OptChoice_3.Text = "Option3"
Me._OptChoice_3.Size = New System.Drawing.Size(225, 17)
Me._OptChoice_3.Location = New System.Drawing.Point(8, 64)
Me._OptChoice_3.TabIndex = 9
Me._OptChoice_3.CheckAlign = System.Drawing.ContentAlignment.MiddleLeft
Me._OptChoice_3.BackColor = System.Drawing.SystemColors.Control
Me._OptChoice_3.CausesValidation = True
Me._OptChoice_3.Enabled = True
Me._OptChoice_3.ForeColor = System.Drawing.SystemColors.ControlText
Me._OptChoice_3.Cursor = System.Windows.Forms.Cursors.Default
Me._OptChoice_3.RightToLeft = System.Windows.Forms.RightToLeft.No
Me._OptChoice_3.Appearance = System.Windows.Forms.Appearance.Normal
Me._OptChoice_3.TabStop = True
Me._OptChoice_3.Checked = False
Me._OptChoice_3.Visible = True
Me._OptChoice_3.Name = "_OptChoice_3"
Me._OptChoice_2.TextAlign = System.Drawing.ContentAlignment.MiddleLeft
Me._OptChoice_2.Text = "Option2"
Me._OptChoice_2.Size = New System.Drawing.Size(233, 17)
Me._OptChoice_2.Location = New System.Drawing.Point(240, 16)
Me._OptChoice_2.TabIndex = 8
Me._OptChoice_2.CheckAlign = System.Drawing.ContentAlignment.MiddleLeft
Me._OptChoice_2.BackColor = System.Drawing.SystemColors.Control
Me._OptChoice_2.CausesValidation = True
Me._OptChoice_2.Enabled = True
Me._OptChoice_2.ForeColor = System.Drawing.SystemColors.ControlText
Me._OptChoice_2.Cursor = System.Windows.Forms.Cursors.Default
Me._OptChoice_2.RightToLeft = System.Windows.Forms.RightToLeft.No
Me._OptChoice_2.Appearance = System.Windows.Forms.Appearance.Normal
Me._OptChoice_2.TabStop = True
Me._OptChoice_2.Checked = False
Me._OptChoice_2.Visible = True
Me._OptChoice_2.Name = "_OptChoice_2"
Me._OptChoice_1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft
Me._OptChoice_1.Text = "Option1"
Me._OptChoice_1.Size = New System.Drawing.Size(225, 17)
Me._OptChoice_1.Location = New System.Drawing.Point(8, 16)
Me._OptChoice_1.TabIndex = 7
Me._OptChoice_1.CheckAlign = System.Drawing.ContentAlignment.MiddleLeft
Me._OptChoice_1.BackColor = System.Drawing.SystemColors.Control
Me._OptChoice_1.CausesValidation = True
Me._OptChoice_1.Enabled = True
Me._OptChoice_1.ForeColor = System.Drawing.SystemColors.ControlText
Me._OptChoice_1.Cursor = System.Windows.Forms.Cursors.Default
Me._OptChoice_1.RightToLeft = System.Windows.Forms.RightToLeft.No
Me._OptChoice_1.Appearance = System.Windows.Forms.Appearance.Normal
Me._OptChoice_1.TabStop = True
Me._OptChoice_1.Checked = False
Me._OptChoice_1.Visible = True
Me._OptChoice_1.Name = "_OptChoice_1"
Me.txtQuestion.AutoSize = False
Me.txtQuestion.Font = New System.Drawing.Font("仿宋_GB2312", 14.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(134, Byte))
Me.txtQuestion.Size = New System.Drawing.Size(489, 169)
Me.txtQuestion.Location = New System.Drawing.Point(8, 8)
Me.txtQuestion.ReadOnly = True
Me.txtQuestion.MultiLine = True
Me.txtQuestion.ScrollBars = System.Windows.Forms.ScrollBars.Vertical
Me.txtQuestion.TabIndex = 0
Me.txtQuestion.AcceptsReturn = True
Me.txtQuestion.TextAlign = System.Windows.Forms.HorizontalAlignment.Left
Me.txtQuestion.BackColor = System.Drawing.SystemColors.Window
Me.txtQuestion.CausesValidation = True
Me.txtQuestion.Enabled = True
Me.txtQuestion.ForeColor = System.Drawing.SystemColors.WindowText
Me.txtQuestion.HideSelection = True
Me.txtQuestion.Maxlength = 0
Me.txtQuestion.Cursor = System.Windows.Forms.Cursors.IBeam
Me.txtQuestion.RightToLeft = System.Windows.Forms.RightToLeft.No
Me.txtQuestion.TabStop = True
Me.txtQuestion.Visible = True
Me.txtQuestion.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
Me.txtQuestion.Name = "txtQuestion"
Me.Controls.Add(txtAnswer)
Me.Controls.Add(CmdSubmit)
Me.Controls.Add(CmdLast)
Me.Controls.Add(CmdNext)
Me.Controls.Add(CmdPrev)
Me.Controls.Add(CmdFirst)
Me.Controls.Add(FrameAnswer)
Me.Controls.Add(txtQuestion)
Me.FrameAnswer.Controls.Add(_ChkChoice_4)
Me.FrameAnswer.Controls.Add(_ChkChoice_3)
Me.FrameAnswer.Controls.Add(_ChkChoice_2)
Me.FrameAnswer.Controls.Add(_ChkChoice_1)
Me.FrameAnswer.Controls.Add(_OptChoice_4)
Me.FrameAnswer.Controls.Add(_OptChoice_3)
Me.FrameAnswer.Controls.Add(_OptChoice_2)
Me.FrameAnswer.Controls.Add(_OptChoice_1)
Me.ChkChoice.SetIndex(_ChkChoice_4, CType(4, Short))
Me.ChkChoice.SetIndex(_ChkChoice_3, CType(3, Short))
Me.ChkChoice.SetIndex(_ChkChoice_2, CType(2, Short))
Me.ChkChoice.SetIndex(_ChkChoice_1, CType(1, Short))
Me.OptChoice.SetIndex(_OptChoice_4, CType(4, Short))
Me.OptChoice.SetIndex(_OptChoice_3, CType(3, Short))
Me.OptChoice.SetIndex(_OptChoice_2, CType(2, Short))
Me.OptChoice.SetIndex(_OptChoice_1, CType(1, Short))
CType(Me.OptChoice, System.ComponentModel.ISupportInitialize).EndInit()
CType(Me.ChkChoice, System.ComponentModel.ISupportInitialize).EndInit()
End Sub
#End Region
#Region "升级支持"
Private Shared m_vb6FormDefInstance As frmAnswer
Private Shared m_InitializingDefInstance As Boolean
Public Shared Property DefInstance() As frmAnswer
Get
If m_vb6FormDefInstance Is Nothing OrElse m_vb6FormDefInstance.IsDisposed Then
m_InitializingDefInstance = True
m_vb6FormDefInstance = New frmAnswer()
m_InitializingDefInstance = False
End If
DefInstance = m_vb6FormDefInstance
End Get
Set
m_vb6FormDefInstance = Value
End Set
End Property
#End Region
Dim iCount As Integer '定义当前题目是试卷中第几道题
Dim Answer As String '定义用户的答案
Dim Ttype As MainModule.QuestionType '定义当前的用户类型
Dim AnswerSet As Boolean '定义用户答案是否已经写入数据库
Private Sub PrepareQuestion(ByVal iCount As Integer) '显示题目并显示用于接收答案的控件
Dim i As Byte
Dim S() As String
Dim QSerial As Integer
QSerial = QPaper.GetQSerial(iCount) '获取题目的试卷编号
txtQuestion.Text = QPaper.GetQuestion(QSerial) '获取题目的问题
Ttype = QPaper.GetType_Renamed(QSerial) '获取试题的类型
FrameAnswer.Visible = False '设置答题所需试卷控件的初始状态
txtAnswer.Visible = False
For i = 1 To 4
OptChoice(i).Visible = False
ChkChoice(i).Visible = False
Next
Select Case Ttype '根据试题类型显示不同的控件
Case MainModule.QuestionType.Blacks, MainModule.QuestionType.EssayQuestion
txtAnswer.Visible = True
Case MainModule.QuestionType.RightOrWrong
FrameAnswer.Visible = True
OptChoice(1).Visible = True
OptChoice(2).Visible = True
OptChoice(1).Text = "对"
OptChoice(2).Text = "错"
Case MainModule.QuestionType.singlesel
FrameAnswer.Visible = True
S = Split(QPaper.GetChoice(QSerial), ",")
For i = 1 To 4
OptChoice(i).Visible = True
OptChoice(i).Text = S(i - 1)
Next
Case MainModule.QuestionType.MultiSel
FrameAnswer.Visible = True
S = Split(QPaper.GetChoice(QSerial), ",")
For i = 1 To 4
ChkChoice(i).Visible = True
ChkChoice(i).Text = S(i - 1)
Next
Case Else
End Select
AnswerSet = False '用户答案还没有写入到数据库中
End Sub
Private Sub SetAnswer() '定义过程将用户答案写入到数据库中
Dim i As Byte
Answer = "" '根据试题类型来获取用户答案
Select Case Ttype
Case MainModule.QuestionType.Blacks, MainModule.QuestionType.EssayQuestion
Answer = txtAnswer.Text
Case MainModule.QuestionType.RightOrWrong
Answer = CStr(OptChoice(1).Checked)
Case MainModule.QuestionType.singlesel
For i = 1 To 4
If OptChoice(i).Checked Then
Answer = CStr(i)
End If
Next
Case MainModule.QuestionType.MultiSel '以逗号进行分割多选题答案
For i = 1 To 4
If ChkChoice(i).CheckState = 1 Then
Answer = Answer & "," & CStr(i)
End If
Next
If Len(Answer) > 0 Then '将第1个多余的逗号去掉
Answer = VB.Right(Answer, Len(Answer) - 1)
End If
'MsgBox Answer
End Select
QPaper.SetAnswer(iCount, Answer) '调用QPaper的SetAnswer方法将答案保存
AnswerSet = True '答案已经被保存
End Sub
Private Sub CmdFirst_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles CmdFirst.Click
If Not AnswerSet Then
SetAnswer()
End If
iCount = 1
PrepareQuestion((iCount))
End Sub
Private Sub CmdLast_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles CmdLast.Click
If Not AnswerSet Then
SetAnswer()
End If
iCount = QPaper.QuestionNum
PrepareQuestion((iCount))
End Sub
Private Sub CmdNext_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles CmdNext.Click
If Not AnswerSet Then
SetAnswer()
End If
If iCount < QPaper.QuestionNum Then
iCount = iCount + 1
PrepareQuestion((iCount))
End If
End Sub
Private Sub CmdPrev_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles CmdPrev.Click
If Not AnswerSet Then
SetAnswer()
End If
If iCount > 1 Then
iCount = iCount - 1
PrepareQuestion((iCount))
End If
End Sub
Private Sub CmdSubmit_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles CmdSubmit.Click
If Not AnswerSet Then
SetAnswer()
End If
Me.Close()
End Sub
Private Sub frmAnswer_Load(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MyBase.Load
iCount = 1
PrepareQuestion((iCount))
End Sub
'UPGRADE_WARNING: Form 事件 frmAnswer.Unload 具有新的行为。 单击以获得更多信息:“ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup2065"”
Private Sub frmAnswer_Closed(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MyBase.Closed
QPaper.Answered = True
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -