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

📄 frmxt.frm

📁 好用的考试系统.rar可以实现简单的功能
💻 FRM
字号:
VERSION 5.00
Begin VB.Form Frmxt 
   Caption         =   "选择考题"
   ClientHeight    =   3045
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   3255
   LinkTopic       =   "Form1"
   ScaleHeight     =   3045
   ScaleWidth      =   3255
   StartUpPosition =   2  '屏幕中心
   Begin VB.CommandButton Cmd_exit 
      Caption         =   "返回"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   10.5
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Left            =   1680
      TabIndex        =   6
      Top             =   2400
      Width           =   1095
   End
   Begin VB.CommandButton Cmd_qd 
      Caption         =   "确定"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   10.5
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Left            =   360
      TabIndex        =   5
      Top             =   2400
      Width           =   1095
   End
   Begin VB.Frame Frmnum 
      Caption         =   "输入考试题数"
      Height          =   1695
      Left            =   240
      TabIndex        =   0
      Top             =   120
      Width           =   2775
      Begin VB.TextBox Txt_sele 
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   12
            Charset         =   134
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   495
         Left            =   1560
         TabIndex        =   2
         Text            =   "20"
         Top             =   360
         Width           =   615
      End
      Begin VB.TextBox Txt_fill 
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   12
            Charset         =   134
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   495
         Left            =   1560
         TabIndex        =   1
         Text            =   "10"
         Top             =   960
         Width           =   615
      End
      Begin VB.Label Label3 
         Caption         =   "选择题数:"
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   12
            Charset         =   134
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   480
         TabIndex        =   4
         Top             =   480
         Width           =   1215
      End
      Begin VB.Label Label4 
         Caption         =   "选择题数:"
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   12
            Charset         =   134
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   480
         TabIndex        =   3
         Top             =   1080
         Width           =   1215
      End
   End
   Begin VB.Label Lblsm 
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H000000FF&
      Height          =   375
      Left            =   240
      TabIndex        =   7
      Top             =   1920
      Width           =   2895
   End
End
Attribute VB_Name = "Frmxt"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim DbPath           As String
Private Sub Cmd_exit_Click()
  Unload Me
End Sub

Private Sub Cmd_qd_Click()
Dim i                As Integer
Dim fillnum          As Integer
Dim selenum          As Integer
'-----------------------------------------------------------------------
'分别打开TestDb.Mdb库中的考试库SeleDb和选择题库TestSeleDb
'-----------------------------------------------------------------------
         Set db = DBEngine.Workspaces(0).OpenDatabase("testdb.mdb")
         Set rsTest = db.OpenRecordset("TestSeleDb")
         Set rsFill = db.OpenRecordset("TestFillDb")
'-----------------------------------------------------------------------
'分别打开Test.Mdb库中的考试库FillDb和选择题库TestFillDb
         Set dbstud = DBEngine.Workspaces(0).OpenDatabase("test.mdb")
         Set rsStudFill = dbstud.OpenRecordset("FillDb")
         Set rsStud = dbstud.OpenRecordset("SeleDb")
'-----------------------------------------------------------------------
'将原来考试选择题库SeleDb的记录都删除
'-----------------------------------------------------------------------
         While Not rsStud.EOF()
           rsStud.Delete
           rsStud.MoveNext
         Wend
         selenum = rsTest.RecordCount
'-----------------------------------------------------------------------
'将原来考试填充题库FillDb的记录都删除
'-----------------------------------------------------------------------
         While Not rsStudFill.EOF()
           rsStudFill.Delete
           rsStudFill.MoveNext
         Wend
         fillnum = rsStudFill.RecordCount
'-----------------------------------------------------------------------
'设置考试库和学生库的索引
'-----------------------------------------------------------------------
'         n = rsTest.RecordCount
         rsTest.Index = "primarykey"          '设置考试选择题库TestSeleDb的索引
         rsFill.Index = "primarykey"          '设置考试填充库TestFillDb的索引
         rsStud.Index = "primarykey"          '设置学生选择题库SeleDb的索引
         rsStudFill.Index = "primarykey"      '设置学生填充题库FillD的索引
'-----------------------------------------------------------------------
'在考试选择库中查找,是否已有该条记录。如果没有找到,则将试题库的该条记录
'加入到考试库中。
'-----------------------------------------------------------------------
         i = 0
         While i < (Txt_sele.Text)
           Randomize (Timer)                  '根据当前时间产生随机种子
           rn = Int((selenum) * Rnd + 1)      '随机产生1~selenum之间的考试选择题库随机数
'-----------------------------------------------------------------------
'产生lowerbound~upperbound之间随机数的公式:
'Int((upperbound - lowerbound + 1) * Rnd + lowerbound)
'-----------------------------------------------------------------------
           rsTest.Seek "=", rn
           If Not rsTest.NoMatch Then
              rsStud.Seek "=", rn
              If rsStud.NoMatch Then
                 rsStud.AddNew
                 rsStud.Fields("id").Value = rsTest.Fields("id").Value
                 rsStud.Fields("se_ti").Value = rsTest.Fields("se_ti").Value
                 rsStud.Fields("se_da").Value = rsTest.Fields("se_da").Value
                 rsStud.Fields("se_dati1").Value = rsTest.Fields("se_dati1").Value
                 rsStud.Fields("se_dati2").Value = rsTest.Fields("se_dati2").Value
                 rsStud.Fields("se_dati3").Value = rsTest.Fields("se_dati3").Value
                 rsStud.Fields("se_dati4").Value = rsTest.Fields("se_dati4").Value
                 rsStud.Update
                 i = i + 1
              End If
            End If
        Wend
'-----------------------------------------------------------------------
         i = 0
         While i < Txt_fill.Text
           Randomize (Timer)                  '根据当前时间产生随机种子
           rn = Int((fillnum) * Rnd + 1)      '随机产生1~fillnum之间的考试填充题库随机数
           rsFill.Seek "=", rn
           If Not rsFill.NoMatch Then
              rsStudFill.Seek "=", rn
              If rsStudFill.NoMatch Then
                 rsStudFill.AddNew
                 rsStudFill.Fields("id").Value = rsFill.Fields("id").Value
                 rsStudFill.Fields("fill_da").Value = rsFill.Fields("fill_da").Value
                 rsStudFill.Fields("fill_ti").Value = rsFill.Fields("fill_ti").Value
                 rsStudFill.Update
                 i = i + 1
              End If
            End If
        Wend
'-----------------------------------------------------------------------
'关闭考试库SeleDb和选择题库TestSeleDb
'-----------------------------------------------------------------------
        rsTest.Close
        Set rsTest = Nothing
        rsStud.Close
        Set rsStud = Nothing
        Cmd_qd.Enabled = False
        Lblsm.Caption = "自动选题完成,请退出"
End Sub

Private Sub Form_Load()
  'DbPath = "d:\"
End Sub

⌨️ 快捷键说明

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