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

📄 frmfill.frm

📁 自测考试系统
💻 FRM
字号:
VERSION 5.00
Begin VB.Form fill 
   Caption         =   "填空题题库管理"
   ClientHeight    =   5385
   ClientLeft      =   60
   ClientTop       =   450
   ClientWidth     =   9690
   LinkTopic       =   "Form1"
   ScaleHeight     =   5385
   ScaleWidth      =   9690
   StartUpPosition =   3  '窗口缺省
   Begin VB.Frame Frame1 
      Height          =   2535
      Left            =   360
      TabIndex        =   15
      Top             =   1800
      Width           =   9015
      Begin VB.TextBox Text4 
         Height          =   270
         Left            =   600
         TabIndex        =   23
         Text            =   "Text6"
         Top             =   1920
         Width           =   8055
      End
      Begin VB.TextBox Text3 
         Height          =   270
         Left            =   600
         TabIndex        =   22
         Text            =   "Text5"
         Top             =   1400
         Width           =   8055
      End
      Begin VB.TextBox Text2 
         Height          =   270
         Left            =   600
         TabIndex        =   21
         Text            =   "Text4"
         Top             =   880
         Width           =   8055
      End
      Begin VB.TextBox Text1 
         Height          =   270
         Left            =   600
         TabIndex        =   20
         Text            =   "Text3"
         Top             =   360
         Width           =   8055
      End
      Begin VB.Label Label7 
         Caption         =   "空4"
         Height          =   375
         Left            =   120
         TabIndex        =   19
         Top             =   1920
         Width           =   495
      End
      Begin VB.Label Label6 
         Caption         =   "空3"
         Height          =   375
         Left            =   120
         TabIndex        =   18
         Top             =   1440
         Width           =   495
      End
      Begin VB.Label Label5 
         Caption         =   "空2"
         Height          =   375
         Left            =   120
         TabIndex        =   17
         Top             =   960
         Width           =   495
      End
      Begin VB.Label Label4 
         Caption         =   "空1"
         Height          =   375
         Left            =   120
         TabIndex        =   16
         Top             =   360
         Width           =   495
      End
   End
   Begin VB.TextBox txtquestion 
      Height          =   975
      Left            =   360
      TabIndex        =   11
      Text            =   "Text1"
      Top             =   360
      Width           =   9015
   End
   Begin VB.TextBox txtpoint 
      BackColor       =   &H8000000E&
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   10.5
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   8640
      TabIndex        =   10
      Text            =   "Text2"
      Top             =   1440
      Width           =   735
   End
   Begin VB.CommandButton cmdadd 
      Caption         =   "添加"
      Height          =   375
      Left            =   2520
      TabIndex        =   9
      Top             =   4440
      Width           =   975
   End
   Begin VB.CommandButton cmddelete 
      Caption         =   "删除"
      Height          =   375
      Left            =   3480
      TabIndex        =   8
      Top             =   4440
      Width           =   975
   End
   Begin VB.CommandButton cmdsave 
      Caption         =   "保存"
      Height          =   375
      Left            =   4440
      TabIndex        =   7
      Top             =   4440
      Width           =   975
   End
   Begin VB.CommandButton cmdexit 
      Caption         =   "退出"
      Height          =   375
      Left            =   5400
      TabIndex        =   6
      Top             =   4440
      Width           =   975
   End
   Begin VB.PictureBox Picnavigation 
      BackColor       =   &H80000009&
      Height          =   255
      Left            =   3000
      ScaleHeight     =   195
      ScaleWidth      =   2835
      TabIndex        =   4
      Top             =   4920
      Width           =   2895
      Begin VB.TextBox txtnews 
         Height          =   390
         Left            =   0
         TabIndex        =   5
         Text            =   "Text7"
         Top             =   0
         Width           =   2895
      End
   End
   Begin VB.CommandButton cmdmove 
      Height          =   255
      Index           =   0
      Left            =   2520
      Picture         =   "frmfill.frx":0000
      Style           =   1  'Graphical
      TabIndex        =   3
      Top             =   4920
      Width           =   255
   End
   Begin VB.CommandButton cmdmove 
      Height          =   255
      Index           =   1
      Left            =   2760
      Picture         =   "frmfill.frx":0482
      Style           =   1  'Graphical
      TabIndex        =   2
      Top             =   4920
      Width           =   255
   End
   Begin VB.CommandButton cmdmove 
      Height          =   255
      Index           =   2
      Left            =   5880
      Picture         =   "frmfill.frx":0948
      Style           =   1  'Graphical
      TabIndex        =   1
      Top             =   4920
      Width           =   255
   End
   Begin VB.CommandButton cmdmove 
      Height          =   255
      Index           =   3
      Left            =   6120
      Picture         =   "frmfill.frx":0E0E
      Style           =   1  'Graphical
      TabIndex        =   0
      Top             =   4920
      Width           =   255
   End
   Begin VB.Label Label1 
      BackColor       =   &H00C0C0FF&
      BackStyle       =   0  'Transparent
      Caption         =   "题干内容"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   14.25
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00FF0000&
      Height          =   255
      Left            =   360
      TabIndex        =   14
      Top             =   0
      Width           =   1215
   End
   Begin VB.Label Label2 
      BackColor       =   &H8000000A&
      BackStyle       =   0  'Transparent
      Caption         =   "参考答案"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   10.5
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   360
      TabIndex        =   13
      Top             =   1560
      Width           =   975
   End
   Begin VB.Label Label3 
      Alignment       =   2  'Center
      BackColor       =   &H8000000A&
      BackStyle       =   0  'Transparent
      Caption         =   "参考分数"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   10.5
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   7680
      TabIndex        =   12
      Top             =   1560
      Width           =   975
   End
End
Attribute VB_Name = "fill"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim isadding As Boolean
Dim objfill As Recordset
Dim objcn As Connection

Private Sub cmdadd_Click()
txtnews = "添加新记录"
txtquestion = ""
Text1 = ""
Text2 = ""
Text3 = ""
Text4 = ""
txtpoint = "1"
isadding = True
txtquestion.SetFocus
End Sub

Private Sub cmddelete_Click()
'根据是否处于添加记录状态执行不同的操作
If isadding Then
'退出添加记录状态,显示当前记录
isadding = False
   If objfill.RecordCount <= 0 Then
      txtnews = "记录:无"
   Else
   show_data
   End If
Else
   If objfill.RecordCount > 0 Then
      If MsgBox("是否删除记录?", vbYesNo + vbQuestion, "阅卷教师信息管理") = vbYes Then
      '执行删除当前记录操作
      objfill.Delete
     '显示下一条记录
      cmdmove(2).Value = True
      Else
      '显示当前记录数据
      show_data
      '显示当前记录和记录总数
      End If
    End If
End If
End Sub

Private Sub cmdexit_Click()
Unload Me
End Sub

Private Sub cmdmove_Click(Index As Integer)
With objfill
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 show_data()
Dim i As Byte
With objfill
If .RecordCount < 1 Then
txtnews = "记录:无" '显示记录提示信息
txtquestion = ""
txtpoint = ""
Text1 = ""
Text2 = ""
Text3 = ""
Text4 = ""
Else
  '显示当前记录数据
  txtquestion = .Fields("题干")
  txtpoint = .Fields("分数")
  Text1 = .Fields("空1")
  Text2 = .Fields("空2")
  Text3 = .Fields("空3")
  Text4 = .Fields("空4")
  '显示当前记录编号和记录总数
  txtnews = "记录" & .AbsolutePosition & "/" & .RecordCount
  End If
End With
End Sub

Private Sub cmdsave_Click()
Dim objcopy As New Recordset
'在当前表中无数据并且不是添加记录时,不执行保存操作
     If Not isadding And objfill.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 = objfill.Clone
        With objcopy
         If .RecordCount > 0 Then
            '检验题干是否重复
            .MoveFirst
            .Find "题干='" & Trim(txtquestion) & "'"
             If (isadding And Not .EOF) Or (Not isadding And Not .EOF And .AbsolutePosition <> objfill.AbsolutePosition) Then
             MsgBox "试题重复,请修改!", vbCritical, "填空题管理"
             txtquestion.SetFocus
             txtquestion.SelStart = 0
             txtquestion.SelLength = Len(txtquestion)
             Exit Sub
             End If
             If isadding Then objfill.AddNew
        Else
            '保存记录
             If isadding Then objfill.AddNew
        End If
        objfill.Fields("题干") = Trim(txtquestion)
        objfill.Fields("分数") = Trim(txtpoint)
        objfill.Fields("空1") = Trim(Text1)
        objfill.Fields("空2") = Trim(Text2)
        objfill.Fields("空3") = Trim(Text3)
        objfill.Fields("空4") = Trim(Text4)
        objfill.Update
        MsgBox "数据保存成功", vbInformation, "填空题管理"
        isadding = False
        '显示当前记录编号和记录总数
        txtnews = "记录:" & objfill.AbsolutePosition & "/" & objfill.RecordCount
        End With
    End If
End Sub



Private Sub Form_Load()
'建立数据库连接
Set objcn = New Connection '定义并实例化连接对象
With objcn '建立连接
           .Provider = "SQLOLEDB"
           .ConnectionString = "user id=sa;data source=(local);" & _
           "initial catalog=自测考试"
           .Open
End With
'获取填空题记录
Set objfill = New Recordset
With objfill
Set .ActiveConnection = objcn
.CursorLocation = adUseClient
.CursorType = adOpenStatic
.LockType = adLockOptimistic
.Open "select * from 填空题"
End With
cmdmove(0).Value = True
End Sub

Private Sub Form_Unload(Cancel As Integer)
objcn.Close
Set objcn = Nothing
Set objfill = Nothing
End Sub


⌨️ 快捷键说明

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