📄 例11.2.frm
字号:
VERSION 5.00
Begin VB.Form Form1
Caption = "学籍资料处理"
ClientHeight = 3480
ClientLeft = 60
ClientTop = 345
ClientWidth = 5070
LinkTopic = "Form1"
ScaleHeight = 3480
ScaleWidth = 5070
StartUpPosition = 3 '窗口缺省
Begin VB.TextBox Text5
DataField = "班号"
DataSource = "Data1"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 390
Left = 3480
TabIndex = 4
Top = 1560
Width = 975
End
Begin VB.CommandButton Comd1
Caption = "查询"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Index = 0
Left = 240
TabIndex = 13
Top = 2400
Width = 735
End
Begin VB.CommandButton Comd1
Caption = "退出"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Index = 4
Left = 4080
TabIndex = 8
Top = 2400
Width = 735
End
Begin VB.CommandButton Comd1
Caption = "删除"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Index = 3
Left = 3120
TabIndex = 7
Top = 2400
Width = 735
End
Begin VB.TextBox Text2
DataField = "姓名"
DataSource = "Data1"
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 = 1
Top = 960
Width = 975
End
Begin VB.TextBox Text3
DataField = "性别"
DataSource = "Data1"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 3480
TabIndex = 2
Top = 960
Width = 975
End
Begin VB.TextBox Text4
DataField = "年龄"
DataSource = "Data1"
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 = 1560
Width = 975
End
Begin VB.CommandButton Comd1
Caption = "修改"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Index = 2
Left = 2160
TabIndex = 6
Top = 2400
Width = 735
End
Begin VB.CommandButton Comd1
Caption = "添加"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Index = 1
Left = 1200
TabIndex = 5
Top = 2400
Width = 735
End
Begin VB.TextBox Text1
DataField = "学号"
DataSource = "Data1"
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 = 0
Top = 360
Width = 975
End
Begin VB.Data Data1
Align = 2 'Align Bottom
Caption = "学籍资料"
Connect = "Access"
DatabaseName = "D:\VB修订版\书中例题\第11章\st.mdb"
DefaultCursorType= 0 '缺省游标
DefaultType = 2 '使用 ODBC
Exclusive = 0 'False
Height = 375
Left = 0
Options = 0
ReadOnly = 0 'False
RecordsetType = 1 'Dynaset
RecordSource = "学籍表"
Top = 3105
Width = 5070
End
Begin VB.Label Label5
Caption = "班号"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 3000
TabIndex = 14
Top = 1680
Width = 615
End
Begin VB.Label Label4
Caption = "年龄"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 840
TabIndex = 12
Top = 1680
Width = 495
End
Begin VB.Label Label3
Caption = "性别"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 3000
TabIndex = 11
Top = 1080
Width = 495
End
Begin VB.Label Label2
Caption = "姓名"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 840
TabIndex = 10
Top = 1080
Width = 495
End
Begin VB.Label Label1
Caption = "学号"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 840
TabIndex = 9
Top = 480
Width = 495
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Data1_Reposition()
Data1.Caption = "第" & Data1.Recordset.AbsolutePosition + 1 & "个记录"
End Sub
Private Sub Data1_Validate(Action As Integer, Save As Integer)
If Save = True Then
y = MsgBox("要保存已更改内容吗?", vbYesNo, "保存记录")
If y = vbNo Then '若回答“否”
Save = False
Data1.UpdateControls '恢复原值
End If
End If
End Sub
Private Sub Comd1_Click(Index As Integer)
Select Case Index
Case 0 '查询记录
s = Trim(InputBox("请输入要查找的学号", "查找"))
xh = "学号='" & s & "'"
Data1.Recordset.FindFirst xh
If Data1.Recordset.NoMatch Then
MsgBox "找不到学号为" & xh & "的学生 ! "
Data1.Recordset.MoveFirst
End If
Case 1 '添加记录
Data1.Recordset.MoveLast '移到记录集的末尾
Data1.Recordset.AddNew '添加新记录
Case 2 '修改记录
Data1.Recordset.Edit '修改当前记录
Case 3 '删除记录
y = MsgBox("要删除该记录吗 ? ", vbYesNo, "删除记录")
If y = vbYes Then
Data1.Recordset.Delete '删除记录
Data1.Recordset.MoveNext '显示下一记录
End If
Case 4 '退出
Unload Me
End Select
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -