📄 editstud.frm
字号:
VERSION 5.00
Begin VB.Form Form3
BorderStyle = 1 'Fixed Single
Caption = "学生信息输入"
ClientHeight = 3030
ClientLeft = 45
ClientTop = 330
ClientWidth = 4005
BeginProperty Font
Name = "Times New Roman"
Size = 9
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
LinkTopic = "Form3"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 3030
ScaleWidth = 4005
StartUpPosition = 2 '屏幕中心
Begin VB.CommandButton Command2
Caption = "取 消"
Height = 375
Left = 2880
TabIndex = 12
Top = 2520
Width = 975
End
Begin VB.CommandButton Command1
Caption = "保 存"
Height = 375
Left = 2880
TabIndex = 11
Top = 1920
Width = 975
End
Begin VB.TextBox Text5
Height = 375
Left = 1200
TabIndex = 4
Top = 2280
Width = 495
End
Begin VB.TextBox Text3
Height = 375
Left = 1200
TabIndex = 2
Top = 1320
Width = 1095
End
Begin VB.TextBox Text2
Height = 375
Left = 1200
TabIndex = 1
Top = 840
Width = 1335
End
Begin VB.TextBox Text1
Height = 375
Left = 1200
TabIndex = 0
Top = 360
Width = 1455
End
Begin VB.Frame Frame1
Caption = "学生情况"
Height = 2775
Left = 120
TabIndex = 5
Top = 120
Width = 2655
Begin VB.TextBox Text4
Height = 375
Left = 1080
TabIndex = 3
Top = 1680
Width = 1095
End
Begin VB.Label Label5
Caption = "借阅量"
Height = 375
Left = 240
TabIndex = 10
Top = 2280
Width = 735
End
Begin VB.Label Label4
Caption = "专业"
Height = 375
Left = 240
TabIndex = 9
Top = 1800
Width = 615
End
Begin VB.Label Label3
Caption = "班 级"
Height = 375
Left = 240
TabIndex = 8
Top = 1320
Width = 735
End
Begin VB.Label Label2
Caption = "姓 名"
Height = 375
Left = 240
TabIndex = 7
Top = 840
Width = 735
End
Begin VB.Label Label1
Caption = "学 号"
Height = 375
Left = 240
TabIndex = 6
Top = 360
Width = 735
End
End
End
Attribute VB_Name = "Form3"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command1_Click() '确定
Dim result As Integer
Dim i, J As Integer
'排错处理
If Text1.text = "" Then
result = MsgBox("学号栏空!", 48, "提示")
Exit Sub
End If
If Text2.text = "" Then
result = MsgBox("姓名栏空!", 48, "提示")
Exit Sub
End If
If Text3.text = "" Then
result = MsgBox("班级栏空!", 48, "提示")
Exit Sub
End If
If Text4.text = "" Then
result = MsgBox("专业栏空!", 48, "提示")
Exit Sub
End If
If Not IsNumeric(Text5.text) Then
result = MsgBox("请输入借阅量!", 48, "提示")
Exit Sub
End If
'增加记录时,检验关键字是否已存在
If flag2 = True Then
form2.Data1.Recordset.MoveLast
form2.Data1.Recordset.MoveFirst
For J = 1 To form2.Data1.Recordset.RecordCount
If form2.Data1.Recordset.Fields("学号") = Text1.text Then
result = MsgBox("此学号已存在,请重新输入!", 48, "提示")
Exit Sub
End If
form2.Data1.Recordset.MoveNext
Next J
End If
If flag2 = True Then '添加新记录
form2!Data1.Recordset.AddNew
Else '修改记录
form2!Data1.Recordset.Edit
End If
'给各个字段赋值
form2.Data1.Recordset.Fields(0) = Text1.text
form2.Data1.Recordset.Fields(1) = Text2.text
form2.Data1.Recordset.Fields(2) = Text3.text
form2.Data1.Recordset.Fields(3) = Text4.text
form2.Data1.Recordset.Fields(4) = Text5.text
form2.Data1.Recordset.Update '更新记录
form2.Data1.Refresh '更新数据库
Unload Form3
End Sub
Private Sub Command2_Click() '退出
Unload Me
End Sub
Private Sub Form_Load() '装载窗体
If flag2 = True Then
Text1.text = "" '添加操作时,对调入界面的初始化
Text2.text = ""
Text3.text = ""
Text4.text = ""
Text5.text = ""
Else
Text1.text = form2.Data1.Recordset.Fields(0) '修改操作时,对调入界面的初始化
Text2.text = form2.Data1.Recordset.Fields(1)
Text3.text = form2.Data1.Recordset.Fields(2)
Text4.text = form2.Data1.Recordset.Fields(3)
Text5.text = form2.Data1.Recordset.Fields(4)
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -