📄 学生名册管理系统.frm
字号:
VERSION 5.00
Begin VB.Form Form1
Caption = "学生名册管理系统"
ClientHeight = 3795
ClientLeft = 1305
ClientTop = 3120
ClientWidth = 6735
ForeColor = &H80000000&
Icon = "学生名册管理系统.frx":0000
LinkTopic = "Form1"
LockControls = -1 'True
MaxButton = 0 'False
Picture = "学生名册管理系统.frx":7D42
ScaleHeight = 3795
ScaleWidth = 6735
Begin VB.CommandButton ComQuit
Caption = "结束&E"
BeginProperty Font
Name = "汉仪娃娃篆简"
Size = 12
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 5280
Picture = "学生名册管理系统.frx":2B28C
Style = 1 'Graphical
TabIndex = 13
Top = 3120
Width = 1215
End
Begin VB.CommandButton ComCancel
Caption = "取消&C"
BeginProperty Font
Name = "汉仪娃娃篆简"
Size = 12
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 5280
Picture = "学生名册管理系统.frx":2B735
Style = 1 'Graphical
TabIndex = 12
Top = 2520
Width = 1215
End
Begin VB.CommandButton ComSave
Caption = "保存&S"
BeginProperty Font
Name = "汉仪娃娃篆简"
Size = 12
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 5280
Picture = "学生名册管理系统.frx":2BBDE
Style = 1 'Graphical
TabIndex = 11
Top = 1920
Width = 1215
End
Begin VB.CommandButton ComDel
Caption = "删除&D"
BeginProperty Font
Name = "汉仪娃娃篆简"
Size = 12
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 5280
Picture = "学生名册管理系统.frx":2C087
Style = 1 'Graphical
TabIndex = 10
Top = 1320
Width = 1215
End
Begin VB.CommandButton ComAdd
Caption = "添加&A"
BeginProperty Font
Name = "汉仪娃娃篆简"
Size = 12
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 5280
Picture = "学生名册管理系统.frx":2C530
Style = 1 'Graphical
TabIndex = 9
Top = 720
Width = 1215
End
Begin VB.CommandButton ComSearch
Caption = "搜索&F"
BeginProperty Font
Name = "汉仪娃娃篆简"
Size = 12
Charset = 134
Weight = 700
Underline = 0 'False
Italic = -1 'True
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 5280
Picture = "学生名册管理系统.frx":2C9D9
Style = 1 'Graphical
TabIndex = 8
Top = 120
Width = 1215
End
Begin VB.TextBox Text1
DataField = "电话"
DataSource = "Data1"
BeginProperty Font
Name = "汉仪娃娃篆简"
Size = 12
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00008000&
Height = 525
Index = 3
Left = 1320
TabIndex = 3
Top = 2280
Width = 3660
End
Begin VB.TextBox Text1
DataField = "生日"
DataSource = "Data1"
BeginProperty Font
Name = "汉仪娃娃篆简"
Size = 12
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00008000&
Height = 525
Index = 2
Left = 1320
TabIndex = 2
Top = 1560
Width = 3660
End
Begin VB.TextBox Text1
DataField = "姓名"
DataSource = "Data1"
BeginProperty Font
Name = "汉仪娃娃篆简"
Size = 12
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00008000&
Height = 525
Index = 1
Left = 1320
TabIndex = 1
Top = 840
Width = 3660
End
Begin VB.TextBox Text1
DataField = "学号"
DataSource = "Data1"
BeginProperty Font
Name = "汉仪娃娃篆简"
Size = 12
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00008000&
Height = 525
Index = 0
Left = 1320
TabIndex = 0
Top = 120
Width = 3660
End
Begin VB.Data Data1
Connect = "Access"
DatabaseName = "D:\access\Student-1.mdb"
DefaultCursorType= 0 '缺省游标
DefaultType = 2 '使用 ODBC
Exclusive = 0 'False
Height = 525
Left = 720
Options = 0
ReadOnly = 0 'False
RecordsetType = 1 'Dynaset
RecordSource = "学生名册"
Top = 3120
Width = 4260
End
Begin VB.Label Label1
Alignment = 1 'Right Justify
BackStyle = 0 'Transparent
Caption = "电话 "
BeginProperty Font
Name = "汉仪娃娃篆简"
Size = 12
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Index = 3
Left = 360
TabIndex = 7
Top = 2400
Width = 855
End
Begin VB.Label Label1
Alignment = 1 'Right Justify
BackStyle = 0 'Transparent
Caption = "生日 "
BeginProperty Font
Name = "汉仪娃娃篆简"
Size = 12
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Index = 2
Left = 360
TabIndex = 6
Top = 1680
Width = 855
End
Begin VB.Label Label1
Alignment = 1 'Right Justify
BackStyle = 0 'Transparent
Caption = "姓名 "
BeginProperty Font
Name = "汉仪娃娃篆简"
Size = 12
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Index = 1
Left = 360
TabIndex = 5
Top = 960
Width = 855
End
Begin VB.Label Label1
Alignment = 1 'Right Justify
BackStyle = 0 'Transparent
Caption = "学号 "
BeginProperty Font
Name = "汉仪娃娃篆简"
Size = 12
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Index = 0
Left = 360
TabIndex = 4
Top = 240
Width = 855
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub ComSearch_Click() '搜索
Dim MyNumber As String '输入搜索的学号
MyNumber = InputBox("请输入学号(6位)", "学号搜索", "830001")
If MyNumber <> "" Then '输入字符串不为空白,且按下确定按钮
MyNumber = "学号='" & MyNumber & " '" '组合搜索字符串
Data1.Recordset.FindFirst MyNumber '寻找学号符合搜索者
End If
End Sub
Private Sub ComAdd_Click() '添加
Dim i As Integer
On Error GoTo apperr
Data1.Recordset.AddNew '添加一组记录数据
For i = 0 To 3
Text1(i).Text = "" '清楚文本框内容
Next
SaveCancel '保存与取消按钮有效
Exit Sub '调离本程序
apperr:
MsgBox Err.Description '显示错误的信息
End Sub
Private Sub ComDel_Click() '删除
Dim s As String
On Error GoTo DelErr '创建删除确定窗口
s = MsgBox("确定删除这笔记录吗?", vbQuestion + vbOKCancel, "删除确定")
If s = 1 Then '确定删除记录数据
BeginTrans
Data1.Recordset.Delete '删除记录
CommitTrans
Data1.Recordset.MoveNext '移至下一条记录
If Data1.Recordset.RecordCount > 0 Then '是否还有记录
If Data1.Recordset.EOF Then '是否移记录指针至最后
Data1.Recordset.MoveLast '移至最后一组记录
End If
End If
End If
Exit Sub '跳离本程序
DelErr:
Rollback '回复错误
MsgBox Err.Description '显示错误信息
End Sub
Private Sub ComSave_Click() '保存
Dim position As Variant
Dim s As String
On Error GoTo updateerr
BeginTrans
Data1.Recordset.Update '数据写入数据库
CommitTrans
Data1.Refresh '重新排序
Initial_Button '回复一般功能按钮
Exit Sub '跳离本程序
updateerr:
Rollback '回复错误
MsgBox Err.Description '显示错误信息
End Sub
Private Sub ComCancel_Click() '取消
On Error GoTo cancelerr
Data1.Recordset.CancelUpdate '取消数据写入
Initial_Button '回复一般功能按钮
Exit Sub '跳离本程序
cancelerr:
MsgBox Err.Description '显示错误信息
End Sub
Private Sub ComQuit_Click() '结束
End
End Sub
Public Sub SaveCancel()
ComSearch.Enabled = False
ComAdd.Enabled = False
ComDel.Enabled = False
ComSave.Enabled = True
ComCancel.Enabled = True
ComQuit.Enabled = False
End Sub
Public Sub Initial_Button()
If Data1.Recordset.RecordCount = 0 Then
ComSearch.Enabled = False
ComAdd.Enabled = True
ComDel.Enabled = False
ComSave.Enabled = False
ComCancel.Enabled = False
ComQuit.Enabled = True
Else
ComSearch.Enabled = True
ComAdd.Enabled = True
ComDel.Enabled = True
ComSave.Enabled = False
ComCancel.Enabled = False
ComQuit.Enabled = True
End If
End Sub
Private Sub form_activate() '窗体有效
Initial_Button
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -