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

📄 frmsjnd.frm

📁  一个题库系统 可以按照试题的难度
💻 FRM
字号:
VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "mscomctl.ocx"
Begin VB.Form frmSJND 
   ClientHeight    =   4968
   ClientLeft      =   48
   ClientTop       =   48
   ClientWidth     =   6900
   ControlBox      =   0   'False
   BeginProperty Font 
      Name            =   "宋体"
      Size            =   10.8
      Charset         =   134
      Weight          =   400
      Underline       =   0   'False
      Italic          =   0   'False
      Strikethrough   =   0   'False
   EndProperty
   LinkTopic       =   "Form1"
   LockControls    =   -1  'True
   ScaleHeight     =   4968
   ScaleWidth      =   6900
   StartUpPosition =   3  '窗口缺省
   Begin VB.Frame Frame1 
      Caption         =   "试卷难度级别定义"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   9
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   -1  'True
         Strikethrough   =   0   'False
      EndProperty
      Height          =   4728
      Left            =   120
      TabIndex        =   0
      Top             =   120
      Width           =   6696
      Begin VB.CommandButton Command5 
         Caption         =   "取消"
         Height          =   360
         Left            =   5616
         TabIndex        =   12
         Top             =   4200
         Width           =   948
      End
      Begin VB.CommandButton Command4 
         Caption         =   "保存"
         Height          =   360
         Left            =   4584
         TabIndex        =   11
         Top             =   4200
         Width           =   948
      End
      Begin VB.CommandButton Command2 
         Caption         =   "移除"
         Height          =   372
         Left            =   5700
         TabIndex        =   10
         Top             =   1764
         Width           =   816
      End
      Begin VB.CommandButton Command1 
         Caption         =   "加入"
         Height          =   372
         Left            =   4776
         TabIndex        =   9
         Top             =   1752
         Width           =   816
      End
      Begin VB.TextBox Text1 
         Height          =   324
         Left            =   5628
         TabIndex        =   5
         Top             =   1188
         Width           =   720
      End
      Begin VB.ComboBox Combo2 
         Height          =   312
         ItemData        =   "frmSJND.frx":0000
         Left            =   5628
         List            =   "frmSJND.frx":0013
         Style           =   2  'Dropdown List
         TabIndex        =   2
         Top             =   744
         Width           =   876
      End
      Begin MSComctlLib.ListView List1 
         Height          =   3972
         Left            =   2148
         TabIndex        =   1
         Top             =   612
         Width           =   2424
         _ExtentX        =   4276
         _ExtentY        =   7006
         LabelEdit       =   1
         LabelWrap       =   -1  'True
         HideSelection   =   0   'False
         FullRowSelect   =   -1  'True
         GridLines       =   -1  'True
         _Version        =   393217
         ForeColor       =   -2147483640
         BackColor       =   -2147483643
         BorderStyle     =   1
         Appearance      =   1
         NumItems        =   0
      End
      Begin MSComctlLib.ListView List2 
         Height          =   3972
         Left            =   132
         TabIndex        =   13
         Top             =   600
         Width           =   1992
         _ExtentX        =   3514
         _ExtentY        =   7006
         LabelEdit       =   1
         LabelWrap       =   -1  'True
         HideSelection   =   0   'False
         HideColumnHeaders=   -1  'True
         FullRowSelect   =   -1  'True
         _Version        =   393217
         ForeColor       =   -2147483640
         BackColor       =   -2147483643
         BorderStyle     =   1
         Appearance      =   1
         NumItems        =   0
      End
      Begin VB.Label Label5 
         AutoSize        =   -1  'True
         Caption         =   "试题难度所占比例"
         Height          =   216
         Left            =   2148
         TabIndex        =   8
         Top             =   360
         Width           =   1728
      End
      Begin VB.Label Label4 
         AutoSize        =   -1  'True
         Caption         =   "试卷难度级别"
         Height          =   216
         Left            =   252
         TabIndex        =   7
         Top             =   360
         Width           =   1296
      End
      Begin VB.Label Label2 
         AutoSize        =   -1  'True
         Caption         =   "%"
         Height          =   216
         Left            =   6396
         TabIndex        =   6
         Top             =   1260
         Width           =   108
      End
      Begin VB.Label Label1 
         AutoSize        =   -1  'True
         Caption         =   "所占比例"
         Height          =   216
         Left            =   4704
         TabIndex        =   4
         Top             =   1236
         Width           =   864
      End
      Begin VB.Label Label3 
         AutoSize        =   -1  'True
         Caption         =   "试题难度"
         Height          =   216
         Left            =   4668
         TabIndex        =   3
         Top             =   804
         Width           =   864
      End
   End
End
Attribute VB_Name = "frmSJND"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private xml_txt As String
Private Type tagSJDY
    STND As String
    SJND As String
    BL As Long
End Type
Dim sjdy_arr() As tagSJDY

Private Sub Combo2_Click()
    Text1.Text = ""
End Sub

Private Sub Command1_Click()
    If Text1.Text = "" Then
        MsgMsg "比例不能为空!"
        Exit Sub
    End If
    If CInt(Text1.Text) > 100 Then
        MsgMsg "比例值不能大于100%!"
        Exit Sub
    End If
    
    Dim icount As Long
    For icount = 0 To UBound(sjdy_arr)
        If sjdy_arr(icount).STND = Combo2.Text And _
            sjdy_arr(icount).SJND = List2.SelectedItem Then
            MsgMsg "在此试卷难度下已经加入此试题难度!"
            Exit Sub
        End If
    Next
    ReDim Preserve sjdy_arr(UBound(sjdy_arr) + 1)
    sjdy_arr(UBound(sjdy_arr)).BL = CInt(Text1.Text)
    sjdy_arr(UBound(sjdy_arr)).STND = Combo2.Text
    sjdy_arr(UBound(sjdy_arr)).SJND = List2.SelectedItem.Text
    
    Dim tmp_item As ListItem
    Set tmp_item = List1.ListItems.Add(, , Combo2.Text)
    tmp_item.SubItems(1) = Text1.Text
End Sub

Private Sub Command2_Click()

    Dim icount As Integer
    For icount = 0 To UBound(sjdy_arr)
        If sjdy_arr(icount).STND = List1.SelectedItem And _
            sjdy_arr(icount).SJND = List2.SelectedItem Then
            sjdy_arr(icount).BL = -1
            sjdy_arr(icount).SJND = "-0"
            sjdy_arr(icount).STND = "-0"
            List1.ListItems.Remove List1.SelectedItem.Index
            Exit Sub
        End If
    Next
End Sub

Private Sub Command4_Click()
    
    Dim tmp_item As ListItem
    
    For Each tmp_item In List2.ListItems
        If Not VertifyBL(tmp_item.Text) Then
            MsgMsg "试卷" & tmp_item.Text & "的比例之和不等于100%"
            Exit Sub
        End If
    Next
    
    
    Dim sSQL As String
    Dim Rs As New ADODB.Recordset
    Dim icount As Long
    
    sSQL = "delete from sjdy"
    dbcon.Execute sSQL
    sSQL = "select * from sjdy"
    Rs.Open sSQL, dbcon, adOpenKeyset, adLockOptimistic, adCmdText
    
    For icount = 0 To UBound(sjdy_arr)
        If sjdy_arr(icount).BL <> 0 Then
            Rs.AddNew
            Rs("BL") = sjdy_arr(icount).BL
            Rs("SJND") = sjdy_arr(icount).SJND
            Rs("STND") = sjdy_arr(icount).STND
            Rs.Update
        End If
    Next
    
    Rs.Close
    
    MsgMsg "保存完毕!"
    
End Sub

Private Sub Command5_Click()
    Unload Me
End Sub

Private Sub Form_Load()
    Dim Rs As New ADODB.Recordset
    Dim sql As String
    Dim xml_txt As String
    
    
    sql = "select * from setings where type='SETING'"
    Rs.Open sql, dbcon, adOpenKeyset, adLockOptimistic, adCmdText
    If (Rs.EOF And Rs.BOF) Or IsNull(Rs("xml_value")) Then
        MsgMsg "请先完成系统设置!"
        Exit Sub
    End If
    xml_txt = Rs("xml_value")
    Rs.Close
    SetNumMask Text1
    SetCombo Combo2, xml_txt, "试题"

    List1.View = lvwReport
    List1.ColumnHeaders.Add , , "试题难度", (List1.Width - 20) / 2
    List1.ColumnHeaders.Add , , "所占比例%", (List1.Width - 20) / 2
    
    
    
    
    List2.View = lvwReport
    List2.ColumnHeaders.Add , , "试卷难度", List1.Width - 20
    
    Dim xml_doc As New MSXML.DOMDocument
    Dim list_nodes As IXMLDOMNodeList
    Dim local_uil As String
    Dim tp_node As node
    Dim node As IXMLDOMElement
    
    xml_doc.loadXML xml_txt
    local_uil = "项目/试卷/ITEM"
    Set list_nodes = xml_doc.getElementsByTagName(local_uil)
    For Each node In list_nodes
        List2.ListItems.Add , , node.Text
    Next
    
    
    ReDim sjdy_arr(0) As tagSJDY
    sjdy_arr(0).BL = -1
    sjdy_arr(0).SJND = "-0"
    sjdy_arr(0).STND = "-0"
    
    GetData
End Sub

Private Sub Form_Resize()
    SetWindowPos Me
End Sub
Private Sub SetCombo(ByRef co_obj As ComboBox, ByVal xml_str As String, ByVal xm1 As String)
    On Error Resume Next
    Dim xml_doc As New MSXML.DOMDocument
    Dim list_nodes As IXMLDOMNodeList
    Dim node As IXMLDOMElement
    Dim local_uil As String
    
    xml_doc.loadXML xml_str
    
    
    local_uil = "项目/" & xm1 & "/ITEM"
    Set list_nodes = xml_doc.getElementsByTagName(local_uil)
    
    co_obj.Clear
    For Each node In list_nodes
        co_obj.AddItem node.Text
    Next
    co_obj.ListIndex = 0
    
End Sub

Private Sub List2_Click()
    List1.ListItems.Clear
    
    Dim tmp_item As ListItem
    Dim icount As Long
    For icount = 0 To UBound(sjdy_arr)
        If sjdy_arr(icount).SJND = List2.SelectedItem.Text Then
            Set tmp_item = List1.ListItems.Add(, , sjdy_arr(icount).STND)
            tmp_item.SubItems(1) = sjdy_arr(icount).BL
        End If
    Next
End Sub

Private Function VertifyBL(ByVal SJND As String) As Boolean
    Dim icount As Long
    Dim l_tmp As Long
    l_tmp = 0
    
    For icount = 0 To UBound(sjdy_arr)
        If sjdy_arr(icount).SJND = SJND Then
            l_tmp = l_tmp + sjdy_arr(icount).BL
        End If
    Next
    If l_tmp <> 100 And l_tmp <> 0 Then
        VertifyBL = False
    Else
        VertifyBL = True
    End If
End Function

Private Sub GetData()
    Dim sSQL As String
    Dim Rs As New ADODB.Recordset
    Dim icount As Long
    
    icount = 0
    sSQL = "select * from sjdy"
    Rs.Open sSQL, dbcon, adOpenKeyset, adLockOptimistic, adCmdText
    ReDim sjdy_arr(Rs.RecordCount) As tagSJDY
    Do While Not Rs.EOF
        sjdy_arr(icount).BL = Rs("bl")
        sjdy_arr(icount).SJND = Rs("sjnd")
        sjdy_arr(icount).STND = Rs("stnd")
        icount = icount + 1
        Rs.MoveNext
    Loop
    Rs.Close
    
    Call List2_Click
End Sub









Private Sub List2_KeyUp(KeyCode As Integer, Shift As Integer)
    List2_Click
End Sub

⌨️ 快捷键说明

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