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

📄 frmjudge.frm

📁 上机考试系统
💻 FRM
字号:
VERSION 5.00
Begin VB.Form Judgement 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "判断题题库管理"
   ClientHeight    =   4530
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   7680
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MDIChild        =   -1  'True
   MinButton       =   0   'False
   ScaleHeight     =   4530
   ScaleWidth      =   7680
   Begin VB.OptionButton Option2 
      Caption         =   "错误"
      Height          =   180
      Left            =   2310
      TabIndex        =   2
      Top             =   1800
      Width           =   705
   End
   Begin VB.OptionButton Option1 
      Caption         =   "正确"
      Height          =   180
      Left            =   1500
      TabIndex        =   1
      Top             =   1800
      Width           =   705
   End
   Begin VB.TextBox txtPoint 
      Height          =   270
      Left            =   4597
      MaxLength       =   1
      TabIndex        =   3
      Text            =   "1"
      Top             =   1755
      Width           =   630
   End
   Begin VB.TextBox txtParse 
      Height          =   1065
      Left            =   705
      MaxLength       =   200
      MultiLine       =   -1  'True
      TabIndex        =   4
      Top             =   2490
      Width           =   6300
   End
   Begin VB.TextBox txtQuestion 
      Height          =   1065
      Left            =   690
      MaxLength       =   100
      MultiLine       =   -1  'True
      TabIndex        =   0
      Top             =   600
      Width           =   6300
   End
   Begin VB.CommandButton cmdSave 
      Caption         =   "保存"
      Height          =   300
      Left            =   3848
      TabIndex        =   7
      Top             =   3765
      Width           =   735
   End
   Begin VB.CommandButton cmdExit 
      Cancel          =   -1  'True
      Caption         =   "退出"
      Height          =   300
      Left            =   4583
      TabIndex        =   8
      Top             =   3765
      Width           =   735
   End
   Begin VB.CommandButton cmdDelete 
      Caption         =   "删除"
      Height          =   300
      Left            =   3098
      TabIndex        =   6
      Top             =   3765
      Width           =   735
   End
   Begin VB.CommandButton cmdAdd 
      Caption         =   "添加"
      Height          =   300
      Left            =   2363
      TabIndex        =   5
      Top             =   3765
      Width           =   735
   End
   Begin VB.PictureBox picNavigation 
      AutoSize        =   -1  'True
      BorderStyle     =   0  'None
      Height          =   350
      Left            =   2768
      ScaleHeight     =   345
      ScaleWidth      =   2415
      TabIndex        =   13
      Top             =   4080
      Width           =   2410
      Begin VB.CommandButton cmdMove 
         Height          =   270
         Index           =   1
         Left            =   270
         Picture         =   "frmJudge.frx":0000
         Style           =   1  'Graphical
         TabIndex        =   10
         Top             =   0
         Width           =   300
      End
      Begin VB.CommandButton cmdMove 
         Height          =   270
         Index           =   0
         Left            =   -15
         Picture         =   "frmJudge.frx":0044
         Style           =   1  'Graphical
         TabIndex        =   9
         Top             =   0
         Width           =   300
      End
      Begin VB.CommandButton cmdMove 
         Height          =   270
         Index           =   3
         Left            =   2010
         Picture         =   "frmJudge.frx":0091
         Style           =   1  'Graphical
         TabIndex        =   12
         Top             =   -15
         Width           =   300
      End
      Begin VB.CommandButton cmdMove 
         Height          =   270
         Index           =   2
         Left            =   1725
         Picture         =   "frmJudge.frx":00DD
         Style           =   1  'Graphical
         TabIndex        =   11
         Top             =   -15
         Width           =   300
      End
      Begin VB.TextBox txtNews 
         Height          =   270
         Left            =   555
         Locked          =   -1  'True
         TabIndex        =   14
         TabStop         =   0   'False
         Top             =   0
         Width           =   1185
      End
   End
   Begin VB.Label Label3 
      AutoSize        =   -1  'True
      Caption         =   "参考分数"
      Height          =   180
      Left            =   3720
      TabIndex        =   18
      Top             =   1800
      Width           =   720
   End
   Begin VB.Label Label4 
      AutoSize        =   -1  'True
      Caption         =   "试题解析"
      Height          =   180
      Left            =   675
      TabIndex        =   17
      Top             =   2190
      Width           =   720
   End
   Begin VB.Label Label1 
      AutoSize        =   -1  'True
      Caption         =   "题干内容"
      Height          =   180
      Left            =   675
      TabIndex        =   16
      Top             =   315
      Width           =   720
   End
   Begin VB.Label Label2 
      AutoSize        =   -1  'True
      Caption         =   "参考答案"
      Height          =   180
      Left            =   675
      TabIndex        =   15
      Top             =   1800
      Width           =   720
   End
End
Attribute VB_Name = "Judgement"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim isAdding As Boolean             '定义操作状态标志
Dim objJudge As Recordset           '用于保存判断题数据表记录
Dim objCn As Connection             '用于建立数据库联接

Private Sub cmdExit_Click()
    Unload Me               '关闭判断题管理窗体
End Sub

Private Sub Form_Load()
    '建立数据库联接
    Set objCn = New Connection                 '实例化联接对象
    With objCn                                 '建立数据库联接
        .Provider = "SQLOLEDB"
        .ConnectionString = "User ID=sa;PWD=123;Data Source=(local);" & _
                            "Initial Catalog=自测考试"
        .Open
    End With
    '获取判断题记录
    Set objJudge = New Recordset                 '实例化objJudge对象
    With objJudge
        Set .ActiveConnection = objCn
        .CursorLocation = adUseClient           '指定使用客户端游标
        .CursorType = adOpenStatic              '指定使用静态游标
        .LockType = adLockOptimistic
        .Open "SELECT * FROM 判断题"            '获取判断题信息
    End With
    cmdMove(0).Value = True                     '触发按钮单击事件,显示第一个记录
End Sub

Private Sub cmdMove_Click(Index As Integer)
    With objJudge
        Select Case Index           '切换当前记录
            Case 0                  '使第一个记录成为当前记录
                If .RecordCount > 0 And Not .BOF Then .MoveFirst
            Case 1                  '使上一个记录成为当前记录
                If .RecordCount > 0 And Not .BOF Then
                    .MovePrevious
                    If .BOF Then .MoveFirst
                End If
            Case 2                  '使下一个记录成为当前记录
                If .RecordCount > 0 And Not .EOF Then
                    .MoveNext
                    If .EOF Then .MoveLast
                End If
            Case 3                  '使最后一个记录成为当前记录
                If .RecordCount > 0 And Not .EOF Then .MoveLast
        End Select
        Show_Data
    End With
    If isAdding Then isAdding = False
End Sub

Private Sub cmdAdd_Click()
    txtNews = "添加新记录"
    txtQuestion = ""
    Option1 = True
    txtPoint = "1"
    txtParse = ""
    isAdding = True
    txtQuestion.SetFocus
End Sub

Private Sub cmdDelete_Click()
    '根据是否处于添加记录状态执行不同的操作
    If isAdding Then
        '退出添加记录状态,显示当前记录
        isAdding = False
        If objJudge.RecordCount <= 0 Then
            txtNews = "记录:无"    '显示无记录提示
        Else
            Show_Data                   '显示当前记录数据
        End If
    Else
        If objJudge.RecordCount > 0 Then
            If MsgBox("是否删除当前记录?", vbYesNo + vbQuestion, _
                       "判断题管理") = vbYes Then
                objJudge.Delete             '执行删除当前记录操作
                
                cmdMove(2).Value = True     '显示下一记录数据
            Else
                Show_Data                   '显示当前记录数据
            End If
        End If
    End If
End Sub
Private Sub cmdSave_Click()
    Dim objCopy As New Recordset
    '在当前表中无数据和不是添加记录时,不执行保存操作
    If Not isAdding And objJudge.RecordCount < 1 Then Exit Sub
    If Trim(txtQuestion) = "" Then
        MsgBox "题干不能为空!", vbCritical, "判断题管理"
        txtQuestion.SetFocus
        txtQuestion = ""
    ElseIf Not txtPoint Like "[1-9]" Then
        MsgBox "请输入有效的分数!", vbCritical, "判断题管理"
        txtPoint.SetFocus
        txtPoint.SelStart = 0
        txtPoint.SelLength = Len(txtPoint)
    Else
        Set objCopy = objJudge.Clone
        With objCopy
            If .RecordCount > 0 Then
                '检查题干是否重复
                .MoveFirst
                .Find "题干='" & Trim(txtQuestion) & "'"
                If (isAdding And Not .EOF) Or _
                    (Not isAdding And Not .EOF And _
                     .AbsolutePosition <> objJudge.AbsolutePosition) Then
                    MsgBox "试题重复,请修改!", vbCritical, "判断题管理"
                    txtQuestion.SetFocus
                    txtQuestion.SelStart = 0
                    txtQuestion.SelLength = Len(txtQuestion)
                    Exit Sub
                End If
                If isAdding Then objJudge.AddNew            '添加新记录
            Else
                If isAdding Then objJudge.AddNew            '添加新记录
            End If
            objJudge.Fields("题干") = Trim(txtQuestion)
            objJudge.Fields("分数") = Trim(txtPoint)
            If Option1 Then
                objJudge.Fields("答案") = True
            Else
                objJudge.Fields("答案") = False
            End If
            If Trim(txtParse) <> "" Then objJudge.Fields("解析") = Trim(txtParse)
            objJudge.Update
            MsgBox "数据保存成功!", vbInformation, "判断题管理"
            isAdding = False
            '显示当前记录编号和记录总数
            txtNews = "记录:" & objJudge.AbsolutePosition & "/" & objJudge.RecordCount
        End With
    End If
End Sub

Private Sub Form_Unload(Cancel As Integer)
    objCn.Close                 '关闭数据联接
    Set objCn = Nothing         '释放数据库联接
    Set objJudge = Nothing      '释放记录集对象
End Sub

'限制分数输入
Private Sub txtPoint_KeyPress(KeyAscii As Integer)
    If Not (Chr(KeyAscii) Like "[1-9]" Or KeyAscii = vbKeyBack) Then
        KeyAscii = 0    '输入不是数字或退格键,取消输入
    End If
End Sub

Private Sub Show_Data()
    Dim i%
    With objJudge
        If .RecordCount < 1 Then
            txtNews = "记录:无"    '显示无记录提示
            '清除显示数据
            txtQuestion = "": txtPoint = "": txtParse = ""
        Else
            '显示当前记录数据
            txtQuestion = .Fields("题干"): txtPoint = .Fields("分数")
            If IsNull(.Fields("解析")) Then
                txtParse = ""
            Else
                txtParse = .Fields("解析")
            End If
            '显示参考答案
            If .Fields("答案") Then
                Option1 = True
            Else
                Option2 = True
            End If
            '显示当前记录编号和记录总数
            txtNews = "记录:" & .AbsolutePosition & "/" & .RecordCount
        End If
    End With
End Sub

⌨️ 快捷键说明

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