📄 form3.frm
字号:
VERSION 5.00
Begin VB.Form Form3
BorderStyle = 3 'Fixed Dialog
Caption = "Form3"
ClientHeight = 3525
ClientLeft = 5475
ClientTop = 3780
ClientWidth = 4125
ControlBox = 0 'False
LinkTopic = "Form3"
MaxButton = 0 'False
MinButton = 0 'False
Picture = "Form3.frx":0000
ScaleHeight = 3525
ScaleWidth = 4125
ShowInTaskbar = 0 'False
Begin VB.CommandButton cmdexit
Caption = "退出"
Height = 375
Left = 3240
Picture = "Form3.frx":804D
Style = 1 'Graphical
TabIndex = 15
Top = 3000
Width = 855
End
Begin VB.CommandButton cmddel
Caption = "删除"
Height = 375
Left = 3240
Picture = "Form3.frx":AB34
Style = 1 'Graphical
TabIndex = 14
Top = 2640
Width = 855
End
Begin VB.CommandButton cmdseek
Caption = "查找"
Height = 375
Left = 3240
Picture = "Form3.frx":D61B
Style = 1 'Graphical
TabIndex = 13
Top = 2280
Width = 855
End
Begin VB.CommandButton cmdedit
Caption = "编辑"
Height = 375
Left = 3240
Picture = "Form3.frx":10102
Style = 1 'Graphical
TabIndex = 12
Top = 1920
Width = 855
End
Begin VB.CommandButton cmdadd
Caption = "添加"
Height = 375
Left = 3240
Picture = "Form3.frx":12BE9
Style = 1 'Graphical
TabIndex = 11
Top = 1560
Width = 855
End
Begin VB.TextBox Text7
DataField = "是否借出"
DataSource = "Data1"
Height = 375
Left = 1080
TabIndex = 6
Top = 3000
Width = 2055
End
Begin VB.TextBox Text1
DataField = "书号"
DataSource = "Data1"
Height = 375
Left = 1080
TabIndex = 0
Top = 60
Width = 2055
End
Begin VB.TextBox Text2
DataField = "自编号"
DataSource = "Data1"
Height = 375
Left = 1080
TabIndex = 1
Top = 600
Width = 2055
End
Begin VB.TextBox Text3
DataField = "书名"
DataSource = "Data1"
Height = 375
Left = 1080
TabIndex = 2
Top = 1080
Width = 2055
End
Begin VB.TextBox Text4
DataField = "作者"
DataSource = "Data1"
Height = 375
Left = 1080
TabIndex = 3
Top = 1560
Width = 2055
End
Begin VB.TextBox Text5
DataField = "出版社"
DataSource = "Data1"
Height = 375
Left = 1080
TabIndex = 4
Top = 2040
Width = 2055
End
Begin VB.TextBox Text6
DataField = "价格"
DataSource = "Data1"
Height = 375
Left = 1080
TabIndex = 5
Top = 2520
Width = 2055
End
Begin VB.Data Data1
Caption = "Data1"
Connect = "Access"
DatabaseName = "E:\qqiao\bysj\book.mdb"
DefaultCursorType= 0 '缺省游标
DefaultType = 2 '使用 ODBC
Exclusive = 0 'False
Height = 375
Left = 120
Options = 0
ReadOnly = 0 'False
RecordsetType = 1 'Dynaset
RecordSource = "book"
Top = 3720
Width = 3495
End
Begin VB.CommandButton cmdlast
Caption = "最后一条"
Height = 375
Left = 3240
Picture = "Form3.frx":156D0
Style = 1 'Graphical
TabIndex = 10
Top = 1200
Width = 855
End
Begin VB.CommandButton cmdnext
Caption = "下一条"
Height = 375
Left = 3240
Picture = "Form3.frx":181B7
Style = 1 'Graphical
TabIndex = 8
Top = 840
Width = 855
End
Begin VB.CommandButton cmdprevious
Caption = "前一条"
Height = 375
Left = 3240
Picture = "Form3.frx":1AC9E
Style = 1 'Graphical
TabIndex = 9
Top = 480
Width = 855
End
Begin VB.CommandButton cmdfirst
Caption = "第一条"
Height = 375
Left = 3240
Picture = "Form3.frx":1D785
Style = 1 'Graphical
TabIndex = 7
Top = 120
Width = 855
End
Begin VB.Label Label1
BackStyle = 0 'Transparent
Caption = "书号:"
Height = 255
Left = 120
TabIndex = 22
Top = 120
Width = 735
End
Begin VB.Label Label2
BackStyle = 0 'Transparent
Caption = "自编号:"
Height = 255
Left = 120
TabIndex = 21
Top = 660
Width = 735
End
Begin VB.Label Label3
BackStyle = 0 'Transparent
Caption = "书名:"
Height = 255
Left = 120
TabIndex = 20
Top = 1140
Width = 735
End
Begin VB.Label Label4
BackStyle = 0 'Transparent
Caption = "作者:"
Height = 255
Left = 120
TabIndex = 19
Top = 1620
Width = 735
End
Begin VB.Label Label5
BackStyle = 0 'Transparent
Caption = "出版社:"
Height = 255
Left = 120
TabIndex = 18
Top = 2100
Width = 735
End
Begin VB.Label Label6
BackStyle = 0 'Transparent
Caption = "价格:"
Height = 255
Left = 120
TabIndex = 17
Top = 2580
Width = 735
End
Begin VB.Label Label7
BackStyle = 0 'Transparent
Caption = "是否借出:"
Height = 255
Left = 0
TabIndex = 16
Top = 3060
Width = 975
End
End
Attribute VB_Name = "Form3"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim db As Database
Dim stnumber, styes As String
Dim a$, b$, c$, d$, e$, f$, g$, h As String
Dim rt As Recordset
Private Sub cmdadd_Click()
Set db = OpenDatabase("E:\qqiao\bysj\book.mdb")
Set rt = db.OpenRecordset("book")
rt.MoveLast
Do
a$ = InputBox("请输入书号:" + Chr(13) + Chr(10) + "(输入end或END结束增加记录)", "增加记录")
If LCase(a$) <> "end" Then '输入书号并赋值给a$,如书号为“end”或者“END”则结束增加记录
rt.AddNew
rt!书号 = a$
b$ = InputBox("请输入自编号:", "增加记录")
rt.Fields("自编号") = b$
c$ = InputBox("请输入书名:", "增加记录")
rt.Fields("书名") = c$
d$ = InputBox("请输入作者:", "增加记录")
rt.Fields("作者") = d$
e$ = InputBox("请输入出版社:", "增加记录")
rt.Fields("出版社") = e$
f$ = InputBox("请输入价格:", "增加记录")
rt.Fields("价格") = f$
g$ = InputBox("请输入是否借出:", "增加记录")
rt.Fields("是否借出") = g$
Text1.Text = a$
Text2.Text = b$
Text3.Text = c$
Text4.Text = d$
Text5.Text = e$
Text6.Text = f$
Text7.Text = g$
rt.Update
Else
Exit Do
End If
Loop
rt.Close
db.Close
End Sub
Private Sub cmddel_Click()
Set db = OpenDatabase("E:\qqiao\bysj\book.mdb")
Set rt = db.OpenRecordset("book")
styes = MsgBox("你确定要删除当前记录?", vbOKCancel, "删除记录")
If styes = vbOK Then
Data1.Recordset.Delete
Data1.Recordset.MoveNext
End If
If Data1.Recordset.EOF = True Then
qq = MsgBox("指向最后一个记录", vbookonly, "错误")
Data1.Recordset.MoveLast
End If
rt.Close
db.Close
End Sub
Private Sub cmdedit_Click()
Set db = OpenDatabase("E:\qqiao\bysj\book.mdb")
Set rt = db.OpenRecordset("book")
h = "no"
a$ = InputBox("请输入书号:", "编辑记录")
rt.MoveFirst
Do While Not rt.EOF
If rt!书号 = a$ Then
rt.Edit
Text1.Text = rt!书号
Text2.Text = rt!自编号
Text3.Text = rt!书名
Text4.Text = rt!作者
Text5.Text = rt!出版社
Text6.Text = rt!价格
Text7.Text = rt!是否借出
rt.Update
h = "yes"
End If
rt.MoveNext
If Data1.Recordset.EOF = True Then
qq = MsgBox("最后一个记录,完成编辑记录!", vbOKOnly, "编辑")
Data1.Recordset.MoveLast
GoTo ok
End If
Loop
ok:
rt.Close
db.Close
If (h = "no") Then
MsgBox "不存在你所要求的编辑修改的书号!"
End If
End Sub
Private Sub cmdexit_Click()
Form1.Show
Form2.Hide
Form3.Hide
Unload help
user.Hide
End Sub
Private Sub cmdfirst_Click()
Data1.Recordset.MoveFirst
End Sub
Private Sub cmdlast_Click()
Data1.Recordset.MoveLast
End Sub
Private Sub cmdnext_Click()
Data1.Recordset.MoveNext
If Data1.Recordset.EOF = True Then
qq = MsgBox("最后一条记录!", vbOKOnly, "错误")
Data1.Recordset.MoveLast
End If
End Sub
Private Sub cmdprevious_Click()
Data1.Recordset.MovePrevious
If Data1.Recordset.BOF = True Then
qq = MsgBox("第一条记录!", vbOKOnly, "错误")
Data1.Recordset.MoveFirst
End If
End Sub
Private Sub cmdseek_Click()
Set db = OpenDatabase("E:\qqiao\bysj\book.mdb")
Set rt = db.OpenRecordset("book")
rt.Index = "书号"
stnumber = InputBox("请输入将要查找的书号:", "查找书号")
rt.Seek "=", stnumber '如果查找成功,则nomatch为false
If rt.NoMatch = False Then '如果查找成功,则显示该记录
Text1.Text = rt!书号
Text2.Text = rt!自编号
Text3.Text = rt!书名
Text4.Text = rt!作者
Text5.Text = rt!出版社
Text6.Text = rt!价格
Text7.Text = rt!是否借出
End If
If rt.NoMatch Then
qq = MsgBox("对不起!没有找到你需要的数据!", vbokonyly, "sorry")
End If
rt.Close
db.Close
End Sub
Private Sub Form_Load()
Data1.Visible = False
Form3.Caption = "图书管理程序"
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -