📄 frmquestion.frm
字号:
Width = 975
End
Begin VB.CommandButton CmdEdit
Appearance = 0 'Flat
BackColor = &H008080FF&
Height = 495
Left = 240
Picture = "frmquestion.frx":17DF
Style = 1 'Graphical
TabIndex = 23
ToolTipText = "编辑题目"
Top = 2400
Width = 1005
End
Begin VB.CommandButton CmdDel
Appearance = 0 'Flat
BackColor = &H008080FF&
Height = 555
Left = 240
Picture = "frmquestion.frx":1869
Style = 1 'Graphical
TabIndex = 22
ToolTipText = "删除该题目"
Top = 3600
Width = 1005
End
Begin VB.CheckBox CheQK
Appearance = 0 'Flat
BackColor = &H00FFFF80&
Caption = "添加时清空"
ForeColor = &H80000008&
Height = 195
Left = 120
TabIndex = 21
Top = 360
Value = 1 'Checked
Visible = 0 'False
Width = 1200
End
Begin VB.CommandButton CmdExit
Appearance = 0 'Flat
BackColor = &H008080FF&
Height = 555
Left = 240
Picture = "frmquestion.frx":18F8
Style = 1 'Graphical
TabIndex = 20
ToolTipText = "关闭窗口"
Top = 4800
Width = 1005
End
End
End
Begin VB.Label Label3
BackColor = &H00FFFFC0&
Caption = "主题词:"
Height = 255
Left = 6240
TabIndex = 29
Top = 240
Width = 1815
End
Begin VB.Label Label2
BackColor = &H00FFFFC0&
Caption = "题类:"
Height = 255
Left = 2400
TabIndex = 28
Top = 240
Width = 1095
End
Begin VB.Label Label1
BackColor = &H00FFFFC0&
Caption = "来自部门:"
Height = 255
Left = 480
TabIndex = 27
Top = 240
Width = 975
End
Begin VB.Label lblLabels
BackStyle = 0 'Transparent
Caption = "难度:"
Height = 255
Index = 3
Left = 4350
TabIndex = 15
Top = 240
Width = 915
End
Begin VB.Label lblLabels
BackStyle = 0 'Transparent
Caption = "问题主体:"
Height = 255
Index = 2
Left = 240
TabIndex = 5
Top = 960
Width = 975
End
End
Begin MSComctlLib.StatusBar Stb
Align = 2 'Align Bottom
Height = 345
Left = 0
TabIndex = 31
Top = 8505
Width = 15240
_ExtentX = 26882
_ExtentY = 609
_Version = 393216
BeginProperty Panels {8E3867A5-8586-11D1-B16A-00C0F0283628}
NumPanels = 5
BeginProperty Panel1 {8E3867AB-8586-11D1-B16A-00C0F0283628}
AutoSize = 1
Object.Width = 7064
EndProperty
BeginProperty Panel2 {8E3867AB-8586-11D1-B16A-00C0F0283628}
AutoSize = 1
Object.Width = 7064
EndProperty
BeginProperty Panel3 {8E3867AB-8586-11D1-B16A-00C0F0283628}
AutoSize = 1
Object.Width = 7064
EndProperty
BeginProperty Panel4 {8E3867AB-8586-11D1-B16A-00C0F0283628}
AutoSize = 2
EndProperty
BeginProperty Panel5 {8E3867AB-8586-11D1-B16A-00C0F0283628}
EndProperty
EndProperty
End
Begin VB.Label Label6
BackColor = &H00FFFF80&
Caption = "题"
BeginProperty Font
Name = "宋体"
Size = 21.75
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 11400
TabIndex = 34
Top = 360
Width = 735
End
Begin VB.Label LabTihao
Alignment = 2 'Center
BackColor = &H00FFFF80&
BeginProperty Font
Name = "宋体"
Size = 36
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 615
Left = 10680
TabIndex = 33
Top = 240
Width = 615
End
Begin VB.Label Label4
Alignment = 2 'Center
BackColor = &H00FFFF80&
Caption = "当前第"
BeginProperty Font
Name = "新宋体"
Size = 21.75
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 615
Left = 9240
TabIndex = 32
Top = 360
Width = 1575
End
End
Attribute VB_Name = "frmquestion"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
'声明部门和题类数组
Dim BumenIdArr() As Long
Dim TileiIdArr() As Long
'标志是添加还是编辑
Dim NewOrEdit As String
'产生选择项
Sub CreateXuanZe()
Dim i As Integer
'自动产生数组控件
For i = 1 To 3
'产生标签
Load LabBiaohao(i)
LabBiaohao(i).Caption = Chr(65 + i) + ":"
LabBiaohao(i).Top = 165 + 850 * i
LabBiaohao(i).Visible = True
'产生文本框
Load TxTXuanZe(i)
TxTXuanZe(i).Top = 100 + 850 * i
TxTXuanZe(i).Visible = True
'产生答案选择框
Load CheDaAn(i)
CheDaAn(i).Caption = Chr(65 + i)
CheDaAn(i).Top = 300 + 350 * i
CheDaAn(i).Visible = True
Next i
'设置cmb控件初始值
' CmbKeMu.ListIndex = 0
' CmbNianji.ListIndex = 0
CmbNanDu.ListIndex = 0
Cmbtilei.ListIndex = 0
CmbBumen.ListIndex = 0
End Sub
Private Sub CheDaAn_Click(Index As Integer)
Dim i As Integer
If OpDan.Value = True Then
For i = 0 To 3
If CheDaAn(i).Value Then
If i <> Index Then
If CheDaAn(Index).Value Then
MsgBox "此题你选择的是<单选>不能有多个答案", vbExclamation, "系统提示"
End If
CheDaAn(Index).Value = False
Exit Sub
End If
End If
Next i
End If
End Sub
Private Sub CmbBumen_keypress(KeyAscii As Integer)
If KeyAscii = 13 Then
Cmbtilei.SetFocus
End If
End Sub
Private Sub Cmbtilei_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
CmbNanDu.SetFocus
End If
End Sub
Private Sub Cmbnandu_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
TxtZhuti.SetFocus
End If
End Sub
Private Sub txtzhutici_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
TxTTM.SetFocus
End If
End Sub
Private Sub opdan_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
TxTXuanZe(0).SetFocus
End If
End Sub
Private Sub opduo_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
TxTXuanZe(0).SetFocus
End If
End Sub
Private Sub txtzhuti_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
TxTTM.SetFocus
End If
End Sub
Private Sub CmdDel_Click()
If CmdDel.Tag = "" Then
MsgBox "你还没有选择要删除的题目!", vbExclamation, "系统提示"
Exit Sub
End If
'========================若此题已被使用则不能删除*****《待做》
Dim adoRs As Recordset
Set adoRs = New Recordset
adoRs.Open "select danxuan,duoxuan from test where kemuid=" & UseKeMuID & " and nianjiid=" & UseNianJiID, adoCn, adOpenStatic, adLockOptimistic
Dim TiID As String
Dim Ntiid As Long
TiID = TrVKeMu.Nodes.Item(Val(CmdDel.Tag)).Text
'获得ID号
Ntiid = Val(Mid(TiID, 2, Len(TiID) - 2))
Do While Not adoRs.EOF
'MsgBox adoRs.Fields("danxuan")
' MsgBox CmdDel.Tag
If CheckTestId(Ntiid, adoRs.Fields("danxuan")) Then
MsgBox "试卷库里以使用此题目,现在不能删除!"
Exit Sub
End If
If CheckTestId(Ntiid, adoRs.Fields("duoxuan")) Then
MsgBox "试卷库里以使用此题目,现在不能删除!"
Exit Sub
End If
adoRs.MoveNext
Loop
Set adoRs = Nothing
Dim Result As String
Result = MsgBox("你确实要删除此题目吗!", vbYesNo + vbExclamation, "提问?")
If Result = vbNo Then Exit Sub
'从数据库中删除题目
Dim sql1 As String
sql1 = "delete * from question where id=" & Ntiid
adoCn.Execute sql1
'从LISTVIEW删除题目
TrVKeMu.Nodes.Remove Val(CmdDel.Tag)
'清除控件内容
ClsTM
CmdDel.Tag = ""
End Sub
'检查试卷库里是否已经用了该题目
Function CheckTestId(ByVal Qid As Long, ByVal IdString) As Boolean
CheckTestId = True
Dim i As Integer
Dim IDArr() As String
If IdString <> "" Then
IDArr = Split(IdString, ",")
For i = 0 To UBound(IDArr)
If Qid = Val(IDArr(i)) Then Exit Function
Next i
End If
CheckTestId = False
End Function
Private Sub CmdEdit_Click()
Dim TiID As String
Dim Ntiid As Integer
If CmdNew.ToolTipText = "添加题目" Then
If CmdDel.Tag = "" And NewOrEdit <> "New" Then
MsgBox "请选择要修改的题目!"
Exit Sub
End If
'========================若此题已被使用则不能修改
Dim adoRs As Recordset
Set adoRs = New Recordset
adoRs.Open "select danxuan,duoxuan from test where kemuid=" & UseKeMuID & " and nianjiid=" & UseNianJiID, adoCn, adOpenStatic, adLockOptimistic
TiID = TrVKeMu.Nodes.Item(Val(CmdDel.Tag)).Text
'获得ID号
Ntiid = Val(Mid(TiID, 2, Len(TiID) - 2))
Do While Not adoRs.EOF
'MsgBox adoRs.Fields("danxuan")
' MsgBox CmdDel.Tag
If CheckTestId(Ntiid, adoRs.Fields("danxuan")) Then
MsgBox "试卷库里已使用此题目,现在不能修改!"
Exit Sub
End If
If CheckTestId(Ntiid, adoRs.Fields("duoxuan")) Then
MsgBox "试卷库里已使用此题目,现在不能删除!"
Exit Sub
End If
adoRs.MoveNext
Loop
Set adoRs = Nothing
SetEnabled True
CmdNew.Picture = ImgLst.ListImages(1).Picture
CmdEdit.Picture = ImgLst.ListImages(2).Picture
CmdNew.ToolTipText = "保存题目"
CmdEdit.ToolTipText = "取消保存"
NewOrEdit = "Edit"
Else
If CmdDel.Tag = "" Then GoTo NoUndo
'返回到原状态
Dim adoTMRs As Recordset
Dim sql As String
Set adoTMRs = New Recordset
TiID = TrVKeMu.Nodes.Item(Val(CmdDel.Tag)).Text
'获得ID号
Ntiid = Val(Mid(TiID, 2, Len(TiID) - 2))
sql = "select * from question where id=" + str(Ntiid)
adoTMRs.Open sql, adoCn, adOpenStatic, adLockOptimistic
'清除控件
ClsTM
PlayTM adoTMRs
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -