附录主页面(MDImain):Private Sub addbook_Click()add_book.ShowEnd SubPrivate Sub addreader_Click()add_reader.ShowEnd SubPrivate Sub adduser_Click()add_user.ShowEnd SubPrivate Sub backbook_Click()back_book.ShowEnd SubPrivate Sub borrowbook_Click()borrow_book.ShowEnd SubPrivate Sub cuibackbook_Click()cuiback_book.ShowEnd SubPrivate Sub findbook_Click()find_book.ShowEnd SubPrivate Sub findreader_Click()find_reader.ShowEnd SubPrivate Sub MDIForm_Load()End SubPrivate Sub modifybook_Click()change_book.ShowEnd SubPrivate Sub modifypwd_Click()change_pwd.ShowEnd SubPrivate Sub modifyreader_Click()change_reader.ShowEnd SubPrivate Sub delbook_Click()del_book.ShowEnd SubPrivate Sub delreder_Click()del_reader.ShowEnd SubPrivate Sub quitsys_Click()EndEnd Sub登陆(login):Option ExplicitDim cnt As Integer '记录确定次数Private Sub Command1_Click()Dim sql As StringDim rs_login As New ADODB.RecordsetIf Trim(txtuser.Text) = "" Then '判断输入的用户名是否为空MsgBox "没有这个用户", vbOKOnly + vbExclamation, ""txtuser.SetFocusElsesql = "select * from 用户表where 用户名='" & txtuser.Text & "'"rs_login.Open sql, conn, adOpenKeyset, adLockPessimisticIf rs_login.EOF = True ThenMsgBox "没有这个用户", vbOKOnly + vbExclamation, ""txtuser.SetFocusElse '检验密码是否正确If Trim(rs_login.Fields(1)) = Trim(txtpwd.Text) ThenuserID = txtuser.Textuserpow = rs_login.Fields(2)rs_login.CloseUnload MeMsgBox "欢迎登录到图书管理系统!", vbOKOnly + vbExclamation, ""MDImain.ShowElseMsgBox "密码不正确", vbOKOnly + vbExclamation, ""txtpwd.SetFocusEnd IfEnd IfEnd Ifcnt = cnt + 1If cnt = 3 ThenUnload MeEnd IfExit SubEnd SubPrivate Sub Command2_Click()Unload MeEnd SubPrivate Sub Form_Load()Dim connectionstring As Stringconnectionstring = "provider=Microsoft.Jet.oledb.4.0;" & _"data source=图书管理系统.mdb"conn.Open connectionstringcnt = 0End Sub添加用户(add_user):Private Sub Command1_Click()Dim sql As StringDim rs_add As New ADODB.RecordsetIf Trim(Text1.Text) = "" ThenMsgBox "用户名不能为空", vbOKOnly + vbExclamation, ""Exit SubText1.SetFocusElsesql = "select * from 用户表"rs_add.Open sql, conn, adOpenKeyset, adLockPessimisticWhile (rs_add.EOF = False)If Trim(rs_add.Fields(0)) = Trim(Text1.T ext) ThenMsgBox "已有这个用户", vbOKOnly + vbExclamation, ""Text1.SetFocusText1.Text = ""Text2.Text = ""Text3.Text = ""Combo1.Text = ""Exit SubElsers_add.MoveNextEnd IfWendIf Trim(Text2.Text) <> Trim(Text3.Text) ThenMsgBox "两次密码不一致", vbOKOnly + vbExclamation, ""Text2.SetFocusText2.Text = ""Text3.Text = ""Exit SubElseIf Trim(Combo1.Text) <> "system" And Trim(Combo1.Text) <> "guest" Then MsgBox "请选择正确的用户权限", vbOKOnly + vbExclamation, ""Combo1.SetFocusCombo1.Text = ""Exit SubElsers_add.AddNewrs_add.Fields(0) = Text1.Textrs_add.Fields(1) = Text2.Textrs_add.Fields(2) = Combo1.Textrs_add.Updaters_add.CloseMsgBox "添加用户成功", vbOKOnly + vbExclamation, ""Unload MeEnd IfEnd IfEnd SubPrivate Sub Command2_Click()Unload MeEnd SubPrivate Sub Form_Load()Combo1.AddItem "system"Combo1.AddItem "guest"If userpow = "guest" Then '权限相关Command1.Enabled = FalseCommand2.Enabled = FalseEnd IfEnd Sub添加读者(add_reader):Option ExplicitDim rs_addreader As New ADODB.RecordsetPrivate Sub Command1_Click()Dim sql As StringIf Trim(Text1.Text) = "" ThenMsgBox "借书证号不能为空", vbOKOnly + vbExclamation, ""Text1.SetFocusExit SubEnd IfIf Trim(Text2.Text) = "" ThenMsgBox "所在单位不能为空", vbOKOnly + vbExclamation, ""Text2.SetFocusExit SubEnd IfIf Trim(Text3.Text) = "" ThenMsgBox "姓名不能为空", vbOKOnly + vbExclamation, ""Text3.SetFocusExit SubEnd IfIf Trim(Text4.Text) = "" ThenMsgBox "性别不能为空", vbOKOnly + vbExclamation, ""Text4.SetFocusExit SubEnd IfIf Trim(Text5.Text) = "" ThenMsgBox "类型不能为空", vbOKOnly + vbExclamation, ""Text5.SetFocusExit SubEnd IfIf Trim(Text6.Text) = "" ThenMsgBox "地址不能为空", vbOKOnly + vbExclamation, ""Text6.SetFocusExit SubEnd Ifsql = "select * from 读者表where 借书证号='" & Text1.T ext & "'" rs_addreader.Open sql, conn, adOpenKeyset, adLockPessimistic If rs_addreader.EOF Thenrs_addreader.AddNewrs_addreader.Fields(0) = Trim(Text1.Text)rs_addreader.Fields(1) = Trim(Text2.Text)rs_addreader.Fields(2) = Trim(Text3.Text)rs_addreader.Fields(3) = Trim(Text4.Text)rs_addreader.Fields(4) = Trim(Text5.T ext)rs_addreader.Fields(5) = Trim(Text6.Text)rs_addreader.UpdateMsgBox "添加读者信息成功!", vbOKOnly, ""Unload MeElseMsgBox "借书证号重复!", vbOKOnly + vbExclamation, ""Text1.SetFocusText1.Text = ""rs_addreader.CloseExit SubEnd IfEnd SubPrivate Sub Command2_Click()Unload MeEnd SubPrivate Sub Form_Load()If userpow = "guest" Then '权限相关Frame2.Enabled = FalseEnd IfEnd Sub删除读者(del_reader):Option ExplicitDim rs_reader As New ADODB.RecordsetPrivate Sub cmdcancel_Click()rs_reader.CancelUpdateDataGrid1.RefreshDataGrid1.AllowAddNew = FalseDataGrid1.AllowUpdate = Falsecmddel.Enabled = Truecmdcancel.Enabled = Falsecmdupdate.Enabled = FalseEnd SubPrivate Sub cmddel_Click()Dim answer As StringOn Error GoT o delerroranswer = MsgBox("确定要删除吗?", vbYesNo, "")If answer = vbYes ThenDataGrid1.AllowDelete = Truers_reader.Deleters_reader.UpdateDataGrid1.RefreshMsgBox "成功删除!", vbOKOnly + vbExclamation, ""DataGrid1.AllowDelete = Falsers_reader.UpdateDataGrid1.RefreshElseExit SubEnd Ifdelerror:If Err.Number <> 0 ThenMsgBox Err.DescriptionEnd IfEnd SubPrivate Sub cmdquit_Click()Unload MeEnd SubPrivate Sub cmdupdate_Click()If Not IsNull(DataGrid1.Bookmark) Thenrs_reader.UpdateEnd Ifcmddel.Enabled = Truecmdcancel.Enabled = Falsecmdupdate.Enabled = FalseDataGrid1.AllowUpdate = FalseMsgBox "修改成功!", vbOKOnly + vbExclamation, ""End SubPrivate Sub Form_Load()Dim sql As StringOn Error GoT o loaderrorsql = "select * from 读者表"rs_reader.CursorLocation = adUseClientrs_reader.Open sql, conn, adOpenKeyset, adLockPessimistic '打开数据库cmdupdate.Enabled = False'设定datagrid控件属性DataGrid1.AllowAddNew = False '不可增加DataGrid1.AllowDelete = False '不可删除DataGrid1.AllowUpdate = FalseIf userpow = "guest" Then '权限相关Frame2.Enabled = FalseEnd IfSet DataGrid1.DataSource = rs_reader'cmdcancel.Enabled = FalseExit Subloaderror:MsgBox Err.DescriptionEnd SubPrivate Sub Form_Unload(Cancel As Integer) Set DataGrid1.DataSource = Nothingrs_reader.CloseEnd Sub修改读者(change_reader):Option ExplicitDim rs_reader As New ADODB.RecordsetPrivate Sub cmdcancel_Click()rs_reader.CancelUpdateDataGrid1.RefreshDataGrid1.AllowAddNew = FalseDataGrid1.AllowUpdate = Falsecmdquit.Enabled = Truecmdchange.Enabled = Truecmdcancel.Enabled = Falsecmdupdate.Enabled = FalseEnd SubPrivate Sub cmdchange_Click()Dim answer As StringOn Error GoT o cmdchangecmdquit.Enabled = Truecmdchange.Enabled = False cmdupdate.Enabled = True cmdcancel.Enabled = TrueDataGrid1.AllowUpdate = True cmdchange:If Err.Number <> 0 ThenMsgBox Err.DescriptionEnd IfEnd SubUnload MeEnd SubPrivate Sub cmdupdate_Click()If Not IsNull(DataGrid1.Bookmark) Thenrs_reader.UpdateEnd Ifcmdquit.Enabled = Truecmdchange.Enabled = Truecmdcancel.Enabled = Falsecmdupdate.Enabled = FalseDataGrid1.AllowUpdate = FalseMsgBox "修改成功!", vbOKOnly + vbExclamation, ""End SubPrivate Sub Form_Load()Dim sql As StringOn Error GoT o loaderrorsql = "select * from 读者表"rs_reader.CursorLocation = adUseClientrs_reader.Open sql, conn, adOpenKeyset, adLockPessimistic '打开数据库cmdupdate.Enabled = False'设定datagrid控件属性DataGrid1.AllowAddNew = False '不可增加DataGrid1.AllowDelete = False '不可删除DataGrid1.AllowUpdate = FalseIf userpow = "guest" Then '权限相关Frame2.Enabled = FalseEnd IfSet DataGrid1.DataSource = rs_reader'cmdcancel.Enabled = FalseExit Subloaderror:MsgBox Err.DescriptionEnd SubPrivate Sub Form_Unload(Cancel As Integer)Set DataGrid1.DataSource = Nothingrs_reader.CloseEnd Sub查询读者(find_reader):Option ExplicitDim rs_findreader As New ADODB.RecordsetDim sql As StringIf Check1.Value = vbChecked ThenIf Trim(sql) = "" Thensql = "借书证号='" & Trim(Text1.T ext & " ") & "'"Elsesql = sql & "and 借书证号='" & Trim(Text1.T ext & " ") & "'"End IfEnd IfIf Check2.Value = vbChecked ThenIf Trim(sql) = "" Thensql = "姓名='" & Trim(Text2.T ext & " ") & "'"Elsesql = sql & "and 姓名='" & Trim(Text2.T ext & " ") & "'"End IfEnd Ifsql = "select * from 读者表where " & sqlrs_findreader.CursorLocation = adUseClientrs_findreader.Open sql, conn, adOpenKeyset, adLockPessimistic DataGrid1.AllowAddNew = FalseDataGrid1.AllowDelete = FalseDataGrid1.AllowUpdate = FalseSet DataGrid1.DataSource = rs_findreader'rs_findreader.CloseEnd SubPrivate Sub Command2_Click()Unload MeEnd Sub添加图书(add_book):Option ExplicitDim rs_addbook As New ADODB.RecordsetPrivate Sub Command1_Click()Dim sql As StringIf Trim(Text1.Text) = "" ThenMsgBox "书号不能为空", vbOKOnly + vbExclamation, ""Text1.SetFocusExit SubEnd IfIf Trim(Text2.Text) = "" ThenMsgBox "分类号不能为空", vbOKOnly + vbExclamation, ""Text2.SetFocusExit SubEnd IfIf Trim(Text3.Text) = "" ThenMsgBox "作者不能为空", vbOKOnly + vbExclamation, ""Text3.SetFocusExit SubEnd IfIf Trim(Text4.Text) = "" ThenMsgBox "出版社不能为空", vbOKOnly + vbExclamation, ""Text4.SetFocusExit SubEnd IfIf Trim(Text5.Text) = "" ThenMsgBox "单价不能为空", vbOKOnly + vbExclamation, ""Text5.SetFocusExit SubEnd Ifsql = "select * from 图书表where 书号='" & Text1.T ext & "'" rs_addbook.Open sql, conn, adOpenKeyset, adLockPessimistic If rs_addbook.EOF Thenrs_addbook.AddNewrs_addbook.Fields(0) = Trim(Text1.Text)rs_addbook.Fields(1) = Trim(Text2.Text)rs_addbook.Fields(2) = Trim(Text3.Text)rs_addbook.Fields(3) = Trim(Text4.Text)rs_addbook.Fields(5) = Trim(Text5.Text)rs_addbook.Fields(4) = "否"rs_addbook.UpdateMsgBox "添加书籍信息成功!", vbOKOnly, ""Unload MeElseMsgBox "书号重复!", vbOKOnly + vbExclamation, ""Text1.SetFocusText1.Text = ""rs_addbook.CloseExit SubEnd IfEnd SubPrivate Sub Command2_Click()Unload MeEnd SubPrivate Sub Form_Load()If userpow = "guest" Then '权限相关Command1.Enabled = FalseCommand2.Enabled = FalseEnd IfEnd Sub删除图书(del_book):Option ExplicitDim rs_book As New ADODB.RecordsetPrivate Sub cmdcancel_Click()rs_book.CancelUpdateDataGrid1.RefreshDataGrid1.AllowAddNew = FalseDataGrid1.AllowUpdate = Falsecmddel.Enabled = Truecmdcancel.Enabled = Falsecmdupdate.Enabled = FalseEnd SubPrivate Sub cmddel_Click()Dim answer As StringOn Error GoT o delerroranswer = MsgBox("确定要删除吗?", vbYesNo, "")If answer = vbYes ThenDataGrid1.AllowDelete = Truers_book.Deleters_book.UpdateDataGrid1.RefreshMsgBox "成功删除!", vbOKOnly + vbExclamation, ""DataGrid1.AllowDelete = FalseElseExit SubEnd Ifdelerror:If Err.Number <> 0 ThenMsgBox Err.DescriptionEnd IfEnd SubPrivate Sub cmdquit_Click()Unload MeEnd SubPrivate Sub cmdupdate_Click()If Not IsNull(DataGrid1.Bookmark) Thenrs_book.UpdateEnd Ifcmddel.Enabled = Truecmdcancel.Enabled = Falsecmdupdate.Enabled = FalseDataGrid1.AllowUpdate = FalseMsgBox "删除成功!", vbOKOnly + vbExclamation, ""End SubPrivate Sub Form_Load()Dim sql As StringOn Error GoT o loaderrorsql = "select * from 图书表"rs_book.CursorLocation = adUseClientrs_book.Open sql, conn, adOpenKeyset, adLockPessimistic '打开数据库cmdupdate.Enabled = False'设定datagrid控件属性DataGrid1.AllowAddNew = False '不可增加DataGrid1.AllowDelete = False '不可删除DataGrid1.AllowUpdate = FalseIf userpow = "guest" Then '权限相关Frame2.Enabled = FalseEnd IfSet DataGrid1.DataSource = rs_book'cmdcancel.Enabled = FalseExit Subloaderror:MsgBox Err.DescriptionEnd SubPrivate Sub Form_Unload(Cancel As Integer)Set DataGrid1.DataSource = Nothingrs_book.CloseEnd Sub修改图书(change_book):Option ExplicitDim rs_book As New ADODB.RecordsetPrivate Sub cmdcancel_Click()rs_book.CancelUpdateDataGrid1.RefreshDataGrid1.AllowAddNew = FalseDataGrid1.AllowUpdate = Falsecmdcancel.Enabled = Falsecmdupdate.Enabled = FalseEnd SubPrivate Sub cmdchange_Click()Dim answer As StringOn Error GoT o cmdchangecmdchange.Enabled = Falsecmdupdate.Enabled = Truecmdcancel.Enabled = TrueDataGrid1.AllowUpdate = Truecmdchange:If Err.Number <> 0 ThenMsgBox Err.DescriptionEnd Ifrs_book.UpdateDataGrid1.RefreshEnd SubPrivate Sub cmdquit_Click()Unload MeEnd SubPrivate Sub cmdupdate_Click()If Not IsNull(DataGrid1.Bookmark) Thenrs_book.UpdateEnd Ifcmdchange.Enabled = Truecmdcancel.Enabled = Falsecmdupdate.Enabled = FalseDataGrid1.AllowUpdate = FalseMsgBox "修改成功!", vbOKOnly + vbExclamation, ""End SubPrivate Sub Form_Load()Dim sql As StringOn Error GoT o loaderrorsql = "select * from 图书表"rs_book.CursorLocation = adUseClientrs_book.Open sql, conn, adOpenKeyset, adLockPessimistic '打开数据库'设定datagrid控件属性DataGrid1.AllowAddNew = False '不可增加DataGrid1.AllowDelete = False '不可删除DataGrid1.AllowUpdate = FalseIf userpow = "guest" Then '权限相关Frame2.Enabled = FalseEnd IfSet DataGrid1.DataSource = rs_bookcmdcancel.Enabled = FalseExit Subloaderror:MsgBox Err.DescriptionEnd SubPrivate Sub Form_Unload(Cancel As Integer)Set DataGrid1.DataSource = Nothingrs_book.CloseEnd Sub查询图书(find_book):Option ExplicitDim panduan As StringPrivate Sub Command1_Click()Dim rs_findbook As New ADODB.RecordsetDim sql As StringIf Check1.Value = vbChecked ThenIf Trim(sql) = "" Thensql = "书号='" & Trim(Text1.T ext & " ") & "'"Elsesql = sql & "and 书号='" & Trim(Text1.T ext & " ") & "'"End IfEnd IfIf Check2.Value = vbChecked ThenIf Trim(sql) = "" Thensql = "作者='" & Trim(Text2.T ext & " ") & "'"Elsesql = sql & "and 作者='" & Trim(Text2.T ext & " ") & "'"End IfEnd IfIf Check3.Value = vbChecked ThenIf Trim(sql) = "" Thensql = "出版单位='" & Trim(Text3.T ext & " ") & "'"Elsesql = sql & "and 出版单位='" & Trim(Text3.Text & " ") & "'"End IfEnd IfIf Check4.Value = vbChecked ThenIf Trim(sql) = "" Thensql = "分类号='" & Trim(Text4.Text & " ") & "'"Elsesql = sql & "and 分类号='" & Trim(Text4.T ext & " ") & "'"End IfEnd IfIf Trim(sql) = "" ThenMsgBox "请选择查询方式!", vbOKOnly + vbExclamationExit SubEnd Ifsql = "select * from 图书表where " & sqlrs_findbook.CursorLocation = adUseClientrs_findbook.Open sql, conn, adOpenKeyset, adLockPessimisticDataGrid1.AllowAddNew = FalseDataGrid1.AllowDelete = FalseDataGrid1.AllowUpdate = FalseSet DataGrid1.DataSource = rs_findbook'rs_findbook.CloseEnd SubPrivate Sub Command2_Click()Unload MeEnd SubPrivate Sub DataGrid1_RowColChange(LastRow As Variant, ByVal LastCol As Integer) book_num = DataGrid1.Columns(0).CellValue(DataGrid1.Bookmark)End Sub修改密码(change(pwd):Private Sub Command1_Click()Dim rs_chang As New ADODB.RecordsetDim sql As StringIf Trim(Text1.Text) <> Trim(T ext2.Text) ThenMsgBox "密码不一致!", vbOKOnly + vbExclamation, ""Text1.SetFocusText1.Text = ""Text2.Text = ""Elsesql = "select * from 用户表where 用户名='" & userID & "'"rs_chang.Open sql, conn, adOpenKeyset, adLockPessimisticrs_chang.Fields(1) = Text1.Textrs_chang.Updaters_chang.CloseMsgBox "密码修改成功", vbOKOnly + vbExclamation, ""Unload MeEnd IfEnd SubPrivate Sub Command2_Click()Unload MeEnd Sub借书(borrow_book):Option ExplicitDim cnt As Integer '记录确定次数Private Sub Command1_Click()Dim sql As StringDim sql2 As StringDim sql3 As StringDim rs_borrow1 As New ADODB.RecordsetDim rs_borrow2 As New ADODB.RecordsetDim rs_borrow3 As New ADODB.RecordsetIf Trim(Text1.Text) = "" Then '判断输入的借书证号是否为空MsgBox "借书证号不可以为空", vbOKOnly + vbExclamation, ""Text1.SetFocusElsesql = "select * from 读者表where 借书证号='" & Text1.Text & "'"rs_borrow1.Open sql, conn, adOpenKeyset, adLockPessimisticIf rs_borrow1.EOF = True ThenMsgBox "没有这个读者", vbOKOnly + vbExclamation, ""Text1.SetFocusElse '检验书号是否正确If Trim(Text2.Text) = "" ThenMsgBox "书号不可以为空!", vbOKOnly + vbExclamation, ""Elsesql2 = "select * from 图书表where 书号='" & Text2.T ext & "'"rs_borrow2.Open sql2, conn, adOpenKeyset, adLockPessimisticIf rs_borrow2.EOF = True ThenMsgBox "对不起,没有这本书!", vbOKOnly, ""Text2.Text = ""Text2.SetFocusElseIf (rs_borrow2.Fields(4)) = "是" ThenMsgBox "对不起,此书已被借出!", vbOKOnly + vbExclamation, ""Text2.Text = ""Text2.SetFocusElsesql3 = "select * from 借书表"rs_borrow3.Open sql3, conn, adOpenKeyset, adLockPessimisticrs_borrow3.AddNewrs_borrow3.Fields("书号") = Trim(T ext2.T ext)rs_borrow3.Fields("借书证号") = Trim(T ext1.Text)rs_borrow3.Fields("借书日期") = Daters_borrow2.Fields("是否借出") = "是"rs_borrow2.Updaters_borrow3.UpdateMsgBox "借书成功!", vbOKOnly, ""Text1_ChangeText2.Text = ""End IfEnd IfEnd IfEnd IfEnd Ifcnt = cnt + 1If cnt = 8 ThenUnload MeEnd IfExit SubEnd SubPrivate Sub Command2_Click()Unload MeEnd SubPrivate Sub Form_Load()cnt = 0End SubPrivate Sub Text1_Change()Dim sql1 As StringDim rs_borrow1 As New Recordsetsql1 = "select * from 借书表where 借书证号='" & Text1.Text & "'"rs_borrow1.CursorLocation = adUseClientrs_borrow1.Open sql1, conn, adOpenKeyset, adLockPessimisticSet DataGrid1.DataSource = rs_borrow1DataGrid1.AllowAddNew = FalseDataGrid1.AllowDelete = FalseDataGrid1.AllowUpdate = FalseEnd Sub还书(back_book):Option ExplicitDim cnt As Integer '记录确定次数Private Sub Command1_Click()Dim sql As StringDim sql2 As StringDim sql3 As StringDim answer As StringDim rs_borrow1 As New ADODB.RecordsetDim rs_borrow2 As New ADODB.RecordsetDim rs_borrow3 As New ADODB.RecordsetIf Trim(Text1.Text) = "" Then '判断输入的借书证号是否为空MsgBox "借书证号不可以为空", vbOKOnly + vbExclamation, ""Text1.SetFocusElsesql = "select * from 借书表where 借书证号='" & Text1.Text & "'"rs_borrow1.Open sql, conn, adOpenKeyset, adLockPessimisticIf rs_borrow1.EOF = True ThenMsgBox "这个读者没有借书,请检查输入是否有错误", vbOKOnly + vbExclamation, ""Text1.Text = ""Text1.SetFocusElse '检验书号是否正确sql3 = "select * from 图书表where 书号= '" & rs_borrow1.Fields(1) & "'"rs_borrow3.Open sql3, conn, adOpenKeyset, adLockPessimisticanswer = MsgBox("确定要还这本书吗?", vbYesNo, "")If answer = vbYes ThenIf rs_borrow1.Fields(3) <> "" ThenMsgBox "此书已经还了,按【确定】删除此条记录", vbOKOnly + vbExclamation, ""rs_borrow1.Deleters_borrow1.UpdateUnload MeElsers_borrow1.Fields(3) = Daters_borrow3.Fields(4) = "否"MsgBox "还书成功!", vbOKOnly, ""DataGrid1.AllowDelete = Falsers_borrow1.Updaters_borrow3.UpdateUnload MeEnd IfElseExit SubEnd IfEnd IfEnd Ifcnt = cnt + 1If cnt = 8 ThenUnload MeEnd IfExit SubEnd SubPrivate Sub Command2_Click()Unload MeEnd SubPrivate Sub Form_Load()cnt = 0End SubPrivate Sub Text1_Change()Dim sql1 As StringDim rs_borrow1 As New Recordsetsql1 = "select * from 借书表where 借书证号='" & Text1.Text & "'" rs_borrow1.CursorLocation = adUseClientrs_borrow1.Open sql1, conn, adOpenKeyset, adLockPessimistic Set DataGrid1.DataSource = rs_borrow1DataGrid1.AllowAddNew = FalseDataGrid1.AllowDelete = FalseDataGrid1.AllowUpdate = FalseEnd Sub。