📄 mdb.frm
字号:
VERSION 5.00
Begin VB.Form Form1
Caption = "图书目录管理"
ClientHeight = 3825
ClientLeft = 2595
ClientTop = 2910
ClientWidth = 8520
LinkTopic = "Form1"
ScaleHeight = 3825
ScaleWidth = 8520
Begin VB.CommandButton Command9
Caption = "查询"
Height = 375
Left = 7080
TabIndex = 17
Top = 3120
Width = 975
End
Begin VB.CommandButton Command8
Caption = "删除"
Height = 375
Left = 5880
TabIndex = 16
Top = 3120
Width = 975
End
Begin VB.CommandButton Command7
Caption = "修改"
Height = 375
Left = 4680
TabIndex = 15
Top = 3120
Width = 975
End
Begin VB.CommandButton Command6
Caption = "新增"
Height = 375
Left = 3480
TabIndex = 14
Top = 3120
Width = 975
End
Begin VB.CommandButton Command2
Caption = "←"
Height = 255
Left = 2280
TabIndex = 13
Top = 480
Width = 375
End
Begin VB.CommandButton Command1
Caption = "●"
Height = 255
Left = 1800
TabIndex = 12
Top = 480
Width = 375
End
Begin VB.CommandButton Command4
Caption = "■"
Height = 255
Left = 3240
TabIndex = 11
Top = 480
Width = 375
End
Begin VB.CommandButton Command3
Caption = "→"
Height = 255
Left = 2760
TabIndex = 10
Top = 480
Width = 375
End
Begin VB.TextBox Text4
DataField = "ISBN"
DataSource = "Data1"
Height = 270
Left = 960
TabIndex = 9
Text = "Text4"
Top = 2400
Width = 7095
End
Begin VB.TextBox Text3
DataField = "Year Published"
DataSource = "Data1"
Height = 270
Left = 960
TabIndex = 8
Text = "Text3"
Top = 1920
Width = 7095
End
Begin VB.TextBox Text2
DataField = "Title"
DataSource = "Data1"
Height = 270
Left = 960
TabIndex = 7
Text = "Text2"
Top = 1440
Width = 7095
End
Begin VB.TextBox Text1
DataField = "PubID"
DataSource = "Data1"
Height = 270
Left = 960
TabIndex = 6
Text = "Text1"
Top = 960
Width = 7095
End
Begin VB.CommandButton Command5
Caption = "离开"
Height = 375
Left = 960
TabIndex = 0
Top = 3120
Width = 975
End
Begin VB.Data Data1
Caption = "图书目录"
Connect = "Access"
DatabaseName = "BIBLIO.MDB"
DefaultCursorType= 0 '缺省游标
DefaultType = 2 '使用 ODBC
Exclusive = 0 'False
Height = 375
Left = 1680
Options = 0
ReadOnly = 0 'False
RecordsetType = 1 'Dynaset
RecordSource = "Titles"
Top = 0
Width = 2055
End
Begin VB.Label Label5
Caption = "ISBN"
Height = 255
Left = 360
TabIndex = 5
Top = 2400
Width = 1215
End
Begin VB.Label Label4
Caption = "年度"
Height = 255
Left = 360
TabIndex = 4
Top = 1920
Width = 1215
End
Begin VB.Label Label3
Caption = "书名"
Height = 255
Left = 360
TabIndex = 3
Top = 1440
Width = 1215
End
Begin VB.Label Label2
Caption = "书号"
Height = 255
Left = 360
TabIndex = 2
Top = 960
Width = 1215
End
Begin VB.Label Label1
Caption = "图书目录管理"
Height = 255
Left = 360
TabIndex = 1
Top = 120
Width = 1215
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim Db As Database
Dim Rs As Recordset
Private Sub Command1_Click()
'Data1.Recordset.MoveFirst
Rs.MoveFirst
Call disprec
End Sub
Private Sub Command2_Click()
'Data1.Recordset.MovePrevious
Rs.MovePrevious
Call disprec
End Sub
Private Sub Command3_Click()
'Data1.Recordset.MoveNext
Rs.MoveNext
Call disprec
End Sub
Private Sub Command4_Click()
'Data1.Recordset.MoveLast
Rs.MoveLast
Call disprec
End Sub
Private Sub Command5_Click()
End
End Sub
Private Sub disprec()
If Not Rs.EOF And Not Rs.BOF Then
Command3.Enabled = True
Command2.Enabled = True
Text1.Text = Rs!pubID
Text2.Text = Rs!Title
Text3.Text = Rs("Year Published")
Text4.Text = Rs!ISBN
Else
If Rs.EOF Then
Command3.Enabled = False
End If
If Rs.BOF Then
Command2.Enabled = False
End If
End If
End Sub
Private Sub Command6_Click()
msg$ = "请输入欲新增的数据,并按左右箭头保存文件"
ans = MsgBox(msg$, vbOKCancel, "新增")
If ans = vbOK Then
Text1.SetFocus
Data1.Recordset.AddNew
End If
'If Command6.Caption = "新增" Then
'Text1 = "": Text2 = "": Text3 = "": Text4 = ""
'Command6.Caption = "确认": Text1.SetFocus
'Else
'Rs.AddNew
'Rs!pubID = Text1.Text: Rs!Title = Text2.Text
'Rs.Update
'Command6.Caption = "新增"
'End If
End Sub
Private Sub Command7_Click()
msg$ = "请输入欲新增的数据,并按左右箭头保存文件"
ans = MsgBox(msg$, vbOKCancel, "新增")
If ans = vbOK Then
Text1.SetFocus
Data1.Recordset.Edit
End If
End Sub
Private Sub Command8_Click()
msg$ = "确定要删除当前记录吗?"
ans = MsgBox(msg$, vbOKCancel, "删除")
If ans = vbOK Then
Text1.SetFocus
Data1.Recordset.Delete
Data1.Recordset.MoveNext
End If
End Sub
Private Sub Command9_Click()
Dim my As Recordset
Set my = Data1.Recordset
my.Index = "Title"
msg$ = "请输入完整的书名"
search$ = InputBox(msg$, "查询")
my.Seek " = ", search$
If my.NoMatch Then
MsgBox "抱歉!没有找到你所要的数据", 16, "没找到"
Data1.Recordset.MoveFirst
End If
End Sub
Private Sub Form_Load()
Set Db = OpenDatabase("BIBLIO.MDB")
Set Rs = Db.OpenRecordset("titles")
Call disprec
End Sub
Private Sub Form_Unload(Cancel As Integer)
Rs.Close: Db.Close
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -