📄 frmclassmodify.frm
字号:
VERSION 5.00
Begin VB.Form frmClassModify
BorderStyle = 1 'Fixed Single
Caption = "添加班级"
ClientHeight = 3690
ClientLeft = 45
ClientTop = 330
ClientWidth = 5385
LinkTopic = "Form2"
MaxButton = 0 'False
MDIChild = -1 'True
MinButton = 0 'False
ScaleHeight = 3690
ScaleWidth = 5385
Begin VB.CommandButton cmdCancel
Caption = "取消"
BeginProperty Font
Name = "Arial"
Size = 9
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 3000
TabIndex = 12
Top = 3120
Width = 1215
End
Begin VB.CommandButton cmdOK
Caption = "确定"
BeginProperty Font
Name = "Arial"
Size = 9
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 1560
TabIndex = 11
Top = 3120
Width = 1215
End
Begin VB.TextBox txtClass
BackColor = &H80000018&
BeginProperty Font
Name = "Arial"
Size = 9
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00000000&
Height = 1215
Index = 6
Left = 840
MultiLine = -1 'True
ScrollBars = 2 'Vertical
TabIndex = 10
Top = 1680
Width = 4335
End
Begin VB.TextBox txtClass
BackColor = &H80000018&
BeginProperty Font
Name = "Arial"
Size = 9
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00000000&
Height = 330
Index = 5
Left = 3480
MaxLength = 8
TabIndex = 8
Text = "Text1"
Top = 1200
Width = 1695
End
Begin VB.TextBox txtClass
BackColor = &H80000018&
BeginProperty Font
Name = "Arial"
Size = 9
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00000000&
Height = 330
Index = 4
Left = 3480
MaxLength = 16
TabIndex = 6
Text = "Text1"
Top = 720
Width = 1695
End
Begin VB.TextBox txtClass
BackColor = &H80000018&
BeginProperty Font
Name = "Arial"
Size = 9
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00000000&
Height = 330
Index = 3
Left = 840
MaxLength = 8
TabIndex = 5
Text = "Text1"
Top = 720
Width = 1695
End
Begin VB.TextBox txtClass
BackColor = &H80000018&
BeginProperty Font
Name = "Arial"
Size = 9
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00000000&
Height = 330
Index = 2
Left = 840
MaxLength = 5
TabIndex = 4
Text = "Text1"
Top = 1200
Width = 1695
End
Begin VB.TextBox txtClass
BackColor = &H80000018&
BeginProperty Font
Name = "Arial"
Size = 9
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00000000&
Height = 330
Index = 1
Left = 3480
MaxLength = 20
TabIndex = 2
Text = "Text1"
Top = 225
Width = 1695
End
Begin VB.TextBox txtClass
BackColor = &H80000018&
BeginProperty Font
Name = "Arial"
Size = 9
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00000000&
Height = 300
Index = 0
Left = 840
MaxLength = 16
TabIndex = 1
Text = "Text1"
Top = 240
Width = 1695
End
Begin VB.Label lblClass
AutoSize = -1 'True
Caption = "班主任:"
BeginProperty Font
Name = "Arial"
Size = 9
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00000000&
Height = 225
Index = 5
Left = 2700
TabIndex = 17
Top = 1260
Width = 720
End
Begin VB.Label lblClass
AutoSize = -1 'True
Caption = "专业:"
BeginProperty Font
Name = "Arial"
Size = 9
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00000000&
Height = 225
Index = 4
Left = 2880
TabIndex = 16
Top = 780
Width = 540
End
Begin VB.Label lblClass
AutoSize = -1 'True
Caption = "学制:"
BeginProperty Font
Name = "Arial"
Size = 9
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00000000&
Height = 225
Index = 3
Left = 240
TabIndex = 15
Top = 780
Width = 540
End
Begin VB.Label lblClass
AutoSize = -1 'True
Caption = "教室:"
BeginProperty Font
Name = "Arial"
Size = 9
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00000000&
Height = 225
Index = 2
Left = 240
TabIndex = 14
Top = 1260
Width = 540
End
Begin VB.Label Label2
AutoSize = -1 'True
Caption = "班级:"
BeginProperty Font
Name = "Arial"
Size = 9
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00000000&
Height = 225
Index = 1
Left = 2880
TabIndex = 13
Top = 285
Width = 540
End
Begin VB.Label lblClass
AutoSize = -1 'True
Caption = "备注:"
BeginProperty Font
Name = "Arial"
Size = 9
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00000000&
Height = 225
Index = 1
Left = 240
TabIndex = 9
Top = 1680
Width = 540
End
Begin VB.Label Label7
AutoSize = -1 'True
BeginProperty Font
Name = "Arial"
Size = 9
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00000000&
Height = 225
Left = 2640
TabIndex = 7
Top = 1260
Width = 45
End
Begin VB.Label Label4
AutoSize = -1 'True
BeginProperty Font
Name = "Arial"
Size = 9
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00000000&
Height = 225
Left = 735
TabIndex = 3
Top = 1260
Width = 45
End
Begin VB.Label lblClass
AutoSize = -1 'True
Caption = "年级:"
BeginProperty Font
Name = "Arial"
Size = 9
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00000000&
Height = 225
Index = 0
Left = 240
TabIndex = 0
Top = 285
Width = 540
End
End
Attribute VB_Name = "frmClassModify"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'----------------------------------frmClassModify.frm----------------------------------
Option Explicit
Dim strSQL As String
Public Sub ClassLoad()
Dim i As Integer
Dim objRecordset As ADODB.Recordset
'如果是修改班级
If blnModifyClass Then
Me.Caption = "修改班级"
strSQL = "select * from Classes where 班级='" & Trim(frmClassBrower.flgClassData.TextMatrix(frmClassBrower.flgClassData.Row, 2)) & "'"
Set objRecordset = ExecuteSQL(strSQL)
objRecordset.MoveFirst
For i = 0 To 6
txtClass(i).Text = objRecordset.Fields(i)
Next
objRecordset.Close
'如果是添加班级
Else
Me.Caption = "添加班级"
For i = 0 To 6
txtClass(i).Text = ""
Next
End If
End Sub
Private Sub cmdOK_Click()
Dim i As Integer
Dim objRecordset As ADODB.Recordset
'判断输入的合法性
For i = 0 To 5
If txtClass(i) = "" Then
MsgBox lblClass(i).Caption & "不能为空!", vbExclamation + vbOKOnly, "警告"
txtClass(i).SetFocus
txtClass(i).SelStart = 0
txtClass(i).SelLength = Len(txtClass(i).Text)
Exit Sub
End If
Next
'如果为修改班级信息
If blnModifyClass = False Then
strSQL = "select * from Classes where 班级='" & Trim(txtClass(1).Text) & "'"
Set objRecordset = ExecuteSQL(strSQL)
If objRecordset.EOF = False Then
MsgBox "已经存在该班级的设置,不能重复!", vbOKOnly, "警告"
txtClass(1).SetFocus
txtClass(1).SelStart = 0
txtClass(1).SelLength = Len(txtClass(1).Text)
objRecordset.Close
Exit Sub
End If
End If
'如果为添加班级信息
strSQL = "delete * from Classes where 班级='" & Trim(txtClass(1).Text) & "'"
Set objRecordset = ExecuteSQL(strSQL)
strSQL = "select * from Classes "
Set objRecordset = ExecuteSQL(strSQL)
objRecordset.AddNew
'添加数据至数据库
For i = 0 To 6
If txtClass(6).Text = "" Then
txtClass(6).Text = "无"
End If
objRecordset.Fields(i) = txtClass(i).Text
Next
'更新数据库
objRecordset.Update
If blnModifyClass Then
Unload Me
Else
For i = 0 To 6
txtClass(i) = ""
Next
End If
End Sub
Private Sub cmdCancel_Click()
Unload Me
End Sub
Private Sub Form_Activate()
txtClass(0).SetFocus
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -