⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 frmanswer.frm

📁 本论文以“计算机考试系统”的开发为背景
💻 FRM
字号:
VERSION 5.00
Begin VB.Form frmAnswer 
   BorderStyle     =   3  'Fixed Dialog
   Caption         =   "选择题考试"
   ClientHeight    =   6465
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   9705
   BeginProperty Font 
      Name            =   "宋体"
      Size            =   10.5
      Charset         =   134
      Weight          =   400
      Underline       =   0   'False
      Italic          =   0   'False
      Strikethrough   =   0   'False
   EndProperty
   LinkTopic       =   "Form1"
   LockControls    =   -1  'True
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   6465
   ScaleWidth      =   9705
   ShowInTaskbar   =   0   'False
   StartUpPosition =   2  '屏幕中心
   Begin VB.CommandButton Command3 
      Caption         =   "交卷"
      Height          =   465
      Left            =   8370
      TabIndex        =   7
      Top             =   1320
      Width           =   1245
   End
   Begin VB.CommandButton Command2 
      Caption         =   "上一题"
      Height          =   465
      Left            =   8370
      TabIndex        =   6
      Top             =   120
      Width           =   1245
   End
   Begin VB.CommandButton Command1 
      Caption         =   "下一题"
      Height          =   465
      Left            =   8370
      TabIndex        =   4
      Top             =   720
      Width           =   1245
   End
   Begin VB.Frame Frame2 
      Caption         =   "题目"
      Height          =   1245
      Left            =   0
      TabIndex        =   3
      Top             =   0
      Width           =   8235
      Begin VB.Label lblDescription 
         BackColor       =   &H8000000A&
         Caption         =   $"frmAnswer.frx":0000
         ForeColor       =   &H000000FF&
         Height          =   855
         Left            =   120
         TabIndex        =   5
         Top             =   240
         Width           =   7935
      End
   End
   Begin VB.Frame Frame1 
      Caption         =   "单选题"
      Height          =   5145
      Left            =   0
      TabIndex        =   0
      Top             =   1290
      Width           =   8235
      Begin VB.CheckBox chkAnswer 
         Caption         =   "A"
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   14.25
            Charset         =   134
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H80000006&
         Height          =   285
         Index           =   0
         Left            =   60
         TabIndex        =   2
         Top             =   240
         Width           =   465
      End
      Begin VB.Label lblAnswer 
         BackColor       =   &H8000000A&
         Caption         =   $"frmAnswer.frx":0127
         ForeColor       =   &H00FF0000&
         Height          =   405
         Index           =   0
         Left            =   600
         TabIndex        =   1
         Top             =   270
         Width           =   7575
         WordWrap        =   -1  'True
      End
   End
End
Attribute VB_Name = "frmAnswer"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
''答案显示项目之间的距离
Private Const mcsinSpace As Single = 200
Private mintCurrentSubject As Integer   ''当前的试题
Private rstMain         As Recordset
Private rstDetail       As Recordset

Private isProgChangeValue   As Boolean

Private Sub chkAnswer_Click(Index As Integer)
Dim i As Integer
Dim strAnswer As String
Static isBusy As Boolean
Dim rst As Recordset
    If isProgChangeValue Then GoTo Proc_Exit
    If Not isBusy Then
        isBusy = True
        If Not rstMain![题目类型] Then
            For i = 0 To chkAnswer.UBound
                If i <> Index Then
                    chkAnswer(i).Value = 0
                Else
                    chkAnswer(i).Value = 1
                    strAnswer = chkAnswer(i).Caption
                End If
            Next i
        Else
            For i = 0 To chkAnswer.UBound
                If chkAnswer(i).Value = 1 Then
                    strAnswer = strAnswer & chkAnswer(i).Caption
                End If
            Next i
        End If
        Set rst = New Recordset
        rst.ActiveConnection = pCN
        rst.Source = "select * from 考生答案 where 准考证号='" & pudtStudent.准考证号 & "' and 题目编号='" & rstMain![题目编号] & "'"
        rst.CursorLocation = adUseClient
        rst.CursorType = adOpenStatic
        rst.LockType = adLockBatchOptimistic
        rst.Open
        rst![考生答案] = strAnswer
        rst.UpdateBatch
        Set rst = Nothing
        isBusy = False
    End If
Proc_Exit:
    
    
End Sub

''下一题
Private Sub Command1_Click()
    If Not rstMain.EOF Then
        Command1.Enabled = True
        Command2.Enabled = True
        rstMain.MoveNext
        If rstMain.RecordCount = rstMain.Bookmark Then
            Command1.Enabled = False
            Command2.Enabled = True
        End If
    Else
        rstMain.MoveLast
    End If
    Call RefreshSubject
End Sub

Private Sub RefreshSubject()
Dim i As Integer
Dim rstAnswer As Recordset

    lblDescription.Caption = rstMain![题目内容]
    Frame1.Caption = IIf(rstMain![题目类型], "多选题", "单选题")
    Me.Caption = "准考证号: " & pudtStudent.准考证号 & " 姓名: " & pudtStudent.考生姓名 & "     当前 第 " & rstMain.Bookmark & " 条"
    
    
    ''得到答题的数据
    Call SetDetail
    
    ''首先卸载当前加载的对象
    For i = 1 To lblAnswer.UBound
        Unload lblAnswer(i)
        Unload chkAnswer(i)
    Next i
    
    isProgChangeValue = True
    chkAnswer(0).Value = 0
    
    For i = 1 To rstDetail.RecordCount - 1
        
        Load chkAnswer(i)
        chkAnswer(i).Left = chkAnswer(0).Left
        
        Load lblAnswer(i)
        lblAnswer(i).Width = lblAnswer(0).Width
        lblAnswer(i).Height = lblAnswer(0).Height
        
        lblAnswer(i).Left = lblAnswer(0).Left
    Next i
    
    rstDetail.MoveFirst
        
    
    chkAnswer(0).Caption = rstDetail![题目编码]
    
    'lblAnswer(i).Left = 10
    
    lblAnswer(0).Caption = rstDetail![备选答案]
    
    rstDetail.MoveNext
    For i = 1 To rstDetail.RecordCount - 1
        
        chkAnswer(i).Caption = rstDetail![题目编码]
        chkAnswer(i).Top = lblAnswer(i - 1).Top + lblAnswer(i - 1).Height + mcsinSpace
                            
        lblAnswer(i).Top = chkAnswer(i).Top
        lblAnswer(i).Caption = rstDetail![备选答案]
        
        lblAnswer(i).Visible = True
        chkAnswer(i).Visible = True
        rstDetail.MoveNext
    Next i
    
    ''如果该题已经做过了,则加载该题的答案
                
    Set rstAnswer = New Recordset
    rstAnswer.CursorLocation = adUseClient
    rstAnswer.LockType = adLockBatchOptimistic
    rstAnswer.CursorType = adOpenStatic
    rstAnswer.Source = "select * from 考生答案 where 准考证号='" & pudtStudent.准考证号 & "' and 题目编号='" & rstMain![题目编号] & "'"
    rstAnswer.ActiveConnection = pCN
    rstAnswer.Open
    
    If Len(rstAnswer![考生答案] & "") > 0 Then
        For i = 0 To chkAnswer.UBound
            If InStr(1, UCase(rstAnswer![考生答案]), UCase(chkAnswer(i).Caption)) > 0 Then
                chkAnswer(i).Value = 1
            End If
        Next i
    End If
    
    
    isProgChangeValue = False
End Sub



''上一题
Private Sub Command2_Click()
    Command1.Enabled = True
    Command2.Enabled = True
    
    rstMain.MovePrevious
    If rstMain.Bookmark = 1 Then
        Command2.Enabled = False
        Command1.Enabled = True
    End If
    Call RefreshSubject
End Sub


''交卷
Private Sub Command3_Click()
Dim rst As Recordset
    If MsgBox("交卷后将不能在进行考试,你真的要交卷了吗?", vbQuestion + vbYesNo) = vbYes Then
        ''整理进行交卷动作
        Set rst = New Recordset
        rst.LockType = adLockBatchOptimistic
        rst.CursorLocation = adUseClient
        rst.CursorType = adOpenStatic
        Set rst.ActiveConnection = pCN
        rst.Source = "select * from 考生 where 准考证号='" & pudtStudent.准考证号 & "'"
        rst.Open
        rst![考生状态] = "已交卷"
        rst.UpdateBatch
        Unload Me
    End If
    
End Sub


Private Sub Form_Load()
    
    Command2.Enabled = False
    
    Set rstMain = New Recordset
    
    rstMain.ActiveConnection = pCN
    rstMain.Source = "select * from 题库主表 where 题目套号=" & pintSetNumber
    rstMain.LockType = adLockBatchOptimistic
    
    rstMain.CursorLocation = adUseClient
    rstMain.CursorType = adOpenStatic
    rstMain.Open

    Call RefreshSubject
    
End Sub

''设置答案信息
Private Sub SetDetail()
    Set rstDetail = Nothing
    Set rstDetail = New Recordset
    rstDetail.ActiveConnection = pCN
    rstDetail.Source = "select * from 题目明细 where 题目编号='" & rstMain![题目编号] & "'"
    
    rstDetail.LockType = adLockPessimistic
    rstDetail.CursorLocation = adUseClient
    rstDetail.CursorType = adOpenStatic
    rstDetail.Open
End Sub

Private Sub Form_Unload(Cancel As Integer)
    Set rstMain = Nothing
    Set rstDetail = Nothing
End Sub

Private Sub lblAnswer_Click(Index As Integer)
    Call chkAnswer_Click(Index)
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -