📄 frmsubjectedit.frm
字号:
VERSION 5.00
Begin VB.Form frmSubjectEdit
BorderStyle = 3 'Fixed Dialog
Caption = "题目编辑"
ClientHeight = 4485
ClientLeft = 45
ClientTop = 330
ClientWidth = 7005
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
LinkTopic = "Form1"
LockControls = -1 'True
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 4485
ScaleWidth = 7005
ShowInTaskbar = 0 'False
StartUpPosition = 2 '屏幕中心
Begin VB.CommandButton Command2
Caption = "返回(&R)"
Height = 465
Left = 5610
TabIndex = 7
Top = 3930
Width = 1305
End
Begin VB.CommandButton Command1
Caption = "保存(&S)"
Height = 465
Left = 3840
TabIndex = 6
Top = 3930
Width = 1305
End
Begin VB.Frame Frame1
Height = 3765
Left = 60
TabIndex = 8
Top = 30
Width = 6855
Begin VB.TextBox Text5
Height = 345
Left = 1110
TabIndex = 4
Top = 2760
Width = 2295
End
Begin VB.TextBox Text4
Height = 345
Left = 1110
TabIndex = 3
Top = 2250
Width = 2295
End
Begin VB.OptionButton Option2
Caption = "多选题"
Height = 285
Left = 2430
TabIndex = 1
Top = 780
Width = 1395
End
Begin VB.OptionButton Option1
Caption = "单选题"
Height = 285
Left = 1140
TabIndex = 0
Top = 780
Width = 1065
End
Begin VB.TextBox Text3
BackColor = &H80000018&
Height = 345
Left = 1110
Locked = -1 'True
TabIndex = 14
Top = 270
Width = 2295
End
Begin VB.TextBox Text2
Height = 375
Left = 1110
TabIndex = 5
Top = 3240
Width = 5625
End
Begin VB.TextBox Text1
Height = 825
Left = 1110
TabIndex = 2
Top = 1230
Width = 5625
End
Begin VB.Label Label7
Caption = "(如果是多选题,请按ABCD的顺序填入答案,例如AB,而不是BA)"
ForeColor = &H000000FF&
Height = 495
Left = 3570
TabIndex = 16
Top = 2730
Width = 2985
End
Begin VB.Label Label6
Caption = "题目答案:"
Height = 210
Left = 120
TabIndex = 15
Top = 2850
Width = 945
End
Begin VB.Label Label5
Caption = "题目备注:"
Height = 210
Left = 120
TabIndex = 13
Top = 3330
Width = 945
End
Begin VB.Label Label4
Caption = "题目分值:"
Height = 210
Left = 120
TabIndex = 12
Top = 2340
Width = 945
End
Begin VB.Label Label3
Caption = "题目类型:"
Height = 210
Left = 120
TabIndex = 11
Top = 810
Width = 945
End
Begin VB.Label Label2
Caption = "题目内容:"
Height = 345
Left = 120
TabIndex = 10
Top = 1260
Width = 1005
End
Begin VB.Label Label1
Caption = "题目编号:"
Height = 210
Left = 120
TabIndex = 9
Top = 360
Width = 945
End
End
End
Attribute VB_Name = "frmSubjectEdit"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
''============================模块说明=================================
''名称:
''功能:
''作者:
''日期:
''备注:
''版本 修改日期 修改人 原因
''====================================================================
Option Explicit
Private mlngID As Long
Private mblnEdit As Boolean
Private mlngSubjectID As Long
Public Function EditSubject(Optional ByVal lngID As Long = 0, Optional lngSubjectSetID As Long)
Dim rst As Recordset
mlngSubjectID = lngSubjectSetID
mlngID = lngID
mblnEdit = IIf(lngID > 0, True, False)
If mblnEdit Then
Set rst = New Recordset
rst.Open "select * from 题库主表 where ID=" & lngID, pCN, adOpenStatic, adLockBatchOptimistic
Text3 = rst![题目编号]
If rst![题目类型] Then
Option2.Value = True
Else
Option1.Value = True
End If
Text1 = rst![题目内容]
Text4 = rst![题目分值]
Text5 = rst![题目答案]
Text2 = rst![题目备注] & ""
Text3.BackColor = &H80000018
Text3.Locked = True
Else
Text3.BackColor = vbWhite
Text3.Locked = False
End If
Set rst = Nothing
Me.Show 1
End Function
Private Sub Command1_Click()
Dim rst As Recordset
Dim strTemp As String
Dim i As Integer
On Error GoTo Proc_Exit
If Len(Text3) = 0 Then
MsgBox "题目编号不为空!", vbInformation
GoTo Proc_Exit
End If
If Len(Text1) = 0 Then
MsgBox "题目内容不为空!", vbInformation
GoTo Proc_Exit
End If
If Len(Text5) = 0 Then
MsgBox "题目答案不为空!", vbInformation
GoTo Proc_Exit
End If
For i = 1 To Len(Text5)
strTemp = Mid(Text5, i, 1)
If Not (Asc(strTemp) >= 65 And Asc(strTemp) <= 90) And Not (Asc(strTemp) >= 97 And Asc(strTemp) <= 122) Then
MsgBox "题目答案必须为字母!", vbInformation
GoTo Proc_Exit
End If
Next i
Set rst = New Recordset
If mblnEdit Then
rst.Open "select * from 题库主表 where ID=" & mlngID, pCN, adOpenStatic, adLockBatchOptimistic
Else
rst.Open "select * from 题库主表", pCN, adOpenStatic, adLockBatchOptimistic
rst.AddNew
End If
rst![题目编号] = Text3
If Option1.Value Then
rst![题目类型] = False
Else
rst![题目类型] = True
End If
rst![题目内容] = Text1
rst![题目分值] = Val(Text4)
rst![题目答案] = UCase(Text5)
rst![题目备注] = Text2
rst![题目套号] = mlngSubjectID
rst.UpdateBatch
Text1 = ""
Text2 = ""
Text3 = ""
Text4 = ""
Text5 = ""
mblnEdit = False
Text3.BackColor = vbWhite
Text3.Locked = False
Proc_Exit:
Set rst = Nothing
If Err.Number <> 0 Then
If Err.Number = -2147467259 Then
MsgBox "题目编号不能重复!", vbInformation
Else
MsgBox "发生意外错误,错误号:" & Err.Number & " 错误描述:" & Err.Description, vbInformation
End If
Err.Clear
End If
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -