永发信息网

懂vb的牛人进来帮帮忙,把这段程序加上注释,很着急谢谢了,解决必给高分!!

答案:3  悬赏:70  手机版
解决时间 2021-06-04 11:45
  • 提问者网友:戎马万世
  • 2021-06-03 21:54

Private Sub cmdOkCancel_Click(Index As Integer)
Select Case Index
Case 0
mAddEditId = "": mAddEditIdName = ""
mAddEditIdClass = "": mAddEditIdDepart = ""
mAddEditIdZhi = ""
If txtBookId.Text = "" Or txtBookIdName = "" Or txtBookIdClass = "" Or txtBookIdDepart = "" Or txtBookIdZhi = "" Then
' Or txtBookIdDepart = "" Or txtBookIdZhi = "" Then
MsgBox "请把借书证内容填写完整!", 0 + 48, "提示"
Exit Sub
End If
mAddEditId = txtBookId
mAddEditIdName = txtBookIdName
mAddEditIdClass = txtBookIdClass
mAddEditIdDepart = txtBookIdDepart
mAddEditIdZhi = txtBookIdZhi
Unload Me
mSave = True
Case 1
mSave = False
Unload Me
End Select
End Sub

Private Sub txtBookId_GotFocus()
txtBookId.BackColor = vbBlue
txtBookId.ForeColor = vbYellow
End Sub

Private Sub txtBookId_LostFocus()
txtBookId.BackColor = vbWhite
txtBookId.ForeColor = vbBlack
End Sub

Dim db As Database
Dim rst As Recordset
Dim db1 As Database
Dim rst1 As Recordset
Private Sub cmdOkCancel_Click(Index As Integer)
Select Case Index
Case 0
If txtBookNum = "" Or txtBookName = "" Or Combo1.Text = "" _
Or txtCost = "" Or Combo2.Text = "" Or txtBookw = "" Or txtBookcbrq = "" Then
MsgBox "请将所有信息填写完整!", 0 + 48, "提示"
Exit Sub
End If
rst.Seek "=", Trim(txtBookNum.Text)
If rst.NoMatch = False Then
MsgBox "此编号已经存在,请填写其它编号!", 0 + 48, "提示"
'txtBookNum.SelText = txtBookNum.Text
txtBookNum.SetFocus
Exit Sub
End If
If Not IsDate(txtBookcbrq.Text) Then
MsgBox "请按照yyyy-mm-dd格式输入出版日期", vbOKOnly + vbExclamation, ""
txtBookcbrq.SetFocus
Exit Sub
End If

rst.AddNew
rst.Fields("图书编号") = Trim(txtBookNum.Text)
rst.Fields("书名") = txtBookName.Text
rst.Fields("类别") = Combo1.Text
rst.Fields("价格") = txtCost.Text
rst.Fields("出版社") = Combo2.Text
rst.Fields("出版日期") = txtBookcbrq.Text
rst.Fields("作者") = txtBookw.Text
rst.Fields("借出次数") = 0
rst.Update
MsgBox "添加成功!按回车继续", 0 + 48, "成功"
txtBookNum.Text = ""
txtBookName = ""
txtCost = ""
Combo1.Text = ""
txtBookChu = ""
txtBookw = ""
txtBookcbrq = ""
txtBookNum.SetFocus
Case 1
Unload Me
End Select
End Sub


Private Sub Form_Load()

Set db = Workspaces(0).OpenDatabase("DataBase\Data.mdb", False)
Set rst = db.OpenRecordset("Book", dbOpenTable)
rst.Index = "图书编号"

Set db1 = Workspaces(0).OpenDatabase("DataBase\Data.mdb", False)
Set rst1 = db1.OpenRecordset("type", dbOpenTable)

Set db2 = Workspaces(0).OpenDatabase("DataBase\Data.mdb", False)
Set rst2 = db2.OpenRecordset("chubanshe", dbOpenTable)

rst2.MoveLast
rst2.MoveFirst
For i = 1 To rst2.RecordCount
Combo2.AddItem rst2.Fields("出版社名")
rst2.MoveNext
If rst2.EOF Then Exit For
Next


TypeAdd
txtBookNum.Text = ""
txtBookName = ""
txtCost = ""
Combo1.Text = ""
Combo2.Text = ""
txtBookw = ""
txtBookcbrq = ""
End Sub

Private Sub Form_Unload(Cancel As Integer)
rst.Close
rst1.Close
db1.Close
db.Close
End Sub
Private Sub TypeAdd()
rst1.MoveLast
rst1.MoveFirst
For i = 1 To rst1.RecordCount
Combo1.AddItem rst1.Fields("类别")
rst1.MoveNext
If rst1.EOF Then Exit For
Next

End Sub

Private Sub cmdOkCancel_Click(Index As Integer)
Select Case Index
Case 0
mAddEditId = txtBookId & vbNullString
mAddEditIdName = txtBookIdName & vbNullString
mAddEditIdClass = txtBookIdClass & vbNullString & " "
mAddEditIdDepart = txtBookIdDepart & vbNullString & " "
mAddEditIdZhi = txtBookIdZhi & vbNullString & " "
mSave = True
Unload Me
Case 1
mSave = False
Unload Me
End Select
End Sub
Private Sub Form_Load()
txtBookId.Text = mAddEditId
txtBookIdName = mAddEditIdName
txtBookIdClass = mAddEditIdClass
txtBookIdDepart = mAddEditIdDepart
txtBookIdZhi = mAddEditIdZhi
End Sub

最佳答案
  • 五星知识达人网友:千夜
  • 2021-06-03 22:26

简单就是长了点,你给多少分啊,先谈谈条件

全部回答
  • 1楼网友:孤独的牧羊人
  • 2021-06-03 23:07
是真长啊,50分,我给你翻译
  • 2楼网友:山有枢
  • 2021-06-03 22:46
确实挺简单。也确实是太长了点
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯