📄 frmjudgement.frm
字号:
VERSION 5.00
Begin VB.Form judgement
Caption = "判断题题库管理"
ClientHeight = 5565
ClientLeft = 60
ClientTop = 450
ClientWidth = 9060
LinkTopic = "Form1"
ScaleHeight = 5565
ScaleWidth = 9060
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton cmdmove
Height = 255
Index = 3
Left = 6000
Picture = "frmjudgement.frx":0000
Style = 1 'Graphical
TabIndex = 16
Top = 4680
Width = 255
End
Begin VB.CommandButton cmdmove
Height = 255
Index = 2
Left = 5760
Picture = "frmjudgement.frx":0482
Style = 1 'Graphical
TabIndex = 15
Top = 4680
Width = 255
End
Begin VB.CommandButton cmdmove
Height = 255
Index = 1
Left = 2640
Picture = "frmjudgement.frx":0948
Style = 1 'Graphical
TabIndex = 14
Top = 4680
Width = 255
End
Begin VB.CommandButton cmdmove
Height = 255
Index = 0
Left = 2400
Picture = "frmjudgement.frx":0E0E
Style = 1 'Graphical
TabIndex = 13
Top = 4680
Width = 255
End
Begin VB.PictureBox Picnavigation
BackColor = &H80000009&
Height = 255
Left = 2880
ScaleHeight = 195
ScaleWidth = 2835
TabIndex = 11
Top = 4680
Width = 2895
Begin VB.TextBox txtnews
Height = 390
Left = 0
TabIndex = 12
Text = "Text3"
Top = 0
Width = 2895
End
End
Begin VB.CommandButton cmdexit
Caption = "退出"
Height = 375
Left = 5280
TabIndex = 10
Top = 4080
Width = 975
End
Begin VB.CommandButton cmdsave
Caption = "保存"
Height = 375
Left = 4320
TabIndex = 9
Top = 4080
Width = 975
End
Begin VB.CommandButton cmddelete
Caption = "删除"
Height = 375
Left = 3360
TabIndex = 8
Top = 4080
Width = 975
End
Begin VB.CommandButton cmdadd
Caption = "添加"
Height = 375
Left = 2400
TabIndex = 7
Top = 4080
Width = 975
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 = 7680
TabIndex = 6
Text = "Text2"
Top = 3120
Width = 735
End
Begin VB.OptionButton Option2
Caption = "错误"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 2400
TabIndex = 4
Top = 3000
Width = 855
End
Begin VB.OptionButton Option1
Caption = "正确"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 1320
TabIndex = 3
Top = 3000
Width = 975
End
Begin VB.TextBox txtquestion
Height = 2055
Left = 240
TabIndex = 1
Text = "Text1"
Top = 720
Width = 8295
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 = 6480
TabIndex = 5
Top = 3120
Width = 1095
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 = 240
TabIndex = 2
Top = 3000
Width = 975
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 = 240
TabIndex = 0
Top = 360
Width = 1215
End
End
Attribute VB_Name = "judgement"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim isadding As Boolean
Dim objjudge As Recordset
Dim objcn As Connection
Private Sub cmdadd_Click()
txtnews = "添加新记录"
txtquestion = ""
Option1 = True
txtpoint = "1"
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 cmdexit_Click()
Unload Me
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 show_data()
Dim i%
With objjudge
If .RecordCount < 1 Then
txtnews = "记录:无" '显示记录提示信息
txtquestion = ""
txtpoint = ""
Else
'显示当前记录数据
txtquestion = .Fields("题干"): txtpoint = .Fields("分数")
If .Fields("答案") Then
Option1 = True
Else
Option2 = True
End If
'显示当前记录编号和记录总数
txtnews = "记录" & .AbsolutePosition & "/" & .RecordCount
End If
End With
End Sub
Private Sub cmdsave_Click()
Dim objcopy As New Recordset
'在当前表中无数据并且不是添加记录时,不执行保存操作
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
objjudge.Update
MsgBox "数据保存成功", vbInformation, "判断题管理"
isadding = False
'显示当前记录编号和记录总数
txtnews = "记录:" & objjudge.AbsolutePosition & "/" & objjudge.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 objjudge = New Recordset
With objjudge
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 objjudge = Nothing
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -