VB代码翻译,急用,先给30分,追加50分
①借书功能的实现:界面如下代码:OptionExplicit在模块级别中使用,强制显式声明模块中的所有变量DimleibieAsString'该读者的类别Dimqixia...
① 借书功能的实现:界面如下
代码:Option Explicit 在模块级别中使用,强制显式声明模块中的所有变量
Dim leibie As String '该读者的类别
Dim qixian As Integer '该读者可以借书的期限
Dim shumu As Integer '该读者已借书数量
Dim maxnum As Integer '该读者借书数量的限制
Private Sub Combo1_Click()
Combo2.ListIndex = Combo1.ListIndex
End Sub
Private Sub Combo2_Click()
Combo1.ListIndex = Combo2.ListIndex
End Sub
Private Sub Command1_Click()
Dim rs_borrowbook As New ADODB.Recordset
Dim sql As String
sql = "select * from 读者信息 where 读者编号='" & Combo1.Text & "'"
rs_borrowbook.Open sql, conn, adOpenKeyset, adLockPessimistic
leibie = rs_borrowbook.Fields(3)
shumu = rs_borrowbook.Fields(8)
rs_borrowbook.Close
sql = "select * from 读者类别 where 种类名称='" & leibie & "'"
rs_borrowbook.Open sql, conn, adOpenKeyset, adLockPessimistic
qixian = rs_borrowbook.Fields(2)
maxnum = rs_borrowbook.Fields(1)
rs_borrowbook.Close
If shumu >= maxnum Then
MsgBox "该读者借书数额已满!", vbOKOnly + vbExclamation
Exit Sub
End If
sql = "select * from 借阅信息"
rs_borrowbook.Open sql, conn, adOpenKeyset, adLockPessimistic
rs_borrowbook.AddNew
rs_borrowbook.Fields(1) = Combo1.Text
rs_borrowbook.Fields(2) = Combo2.Text
rs_borrowbook.Fields(3) = Label8.Caption
rs_borrowbook.Fields(4) = Label9.Caption
rs_borrowbook.Fields(5) = Date
rs_borrowbook.Fields(6) = DateAdd("Ww", qixian, Date)
rs_borrowbook.Update
rs_borrowbook.Close
sql = "select * from 书籍信息 where 书籍编号='" & book_num & "'"
rs_borrowbook.Open sql, conn, adOpenKeyset, adLockPessimistic
rs_borrowbook.Fields(7) = "是"
rs_borrowbook.Update
rs_borrowbook.Close
sql = "select * from 读者信息 where 读者编号='" & Combo1.Text & "'"
rs_borrowbook.Open sql, conn, adOpenKeyset, adLockPessimistic
rs_borrowbook.Fields(8) = rs_borrowbook.Fields(8) + 1
rs_borrowbook.Update
rs_borrowbook.Close
MsgBox "本书借阅成功!", vbOKOnly + vbExclamation
Unload Me
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Form_Load()
Dim rs_borrow As New ADODB.Recordset
Dim rs_reader As New ADODB.Recordset
Dim sql As String
sql = "select * from 书籍信息 where 书籍编号='" & book_num & "'"
rs_borrow.Open sql, conn, adOpenKeyset, adLockPessimistic
Label8.Caption = rs_borrow.Fields(0)
Label9.Caption = rs_borrow.Fields(1)
Label10.Caption = rs_borrow.Fields(2)
Label11.Caption = rs_borrow.Fields(3)
Label12.Caption = rs_borrow.Fields(4)
Label13.Caption = rs_borrow.Fields(5)
Label14.Caption = rs_borrow.Fields(6)
sql = "select * from 读者信息"
rs_reader.Open sql, conn, adOpenKeyset, adLockPessimistic
If Not rs_reader.EOF Then
Do While Not rs_reader.EOF
Combo1.AddItem rs_reader.Fields(1)
Combo2.AddItem rs_reader.Fields(0)
rs_reader.MoveNext
Loop
Else
MsgBox "请先登记读者!", vbOKOnly + vbExclamation
Exit Sub
End If
rs_borrow.Close
rs_reader.Close
End Sub 展开
代码:Option Explicit 在模块级别中使用,强制显式声明模块中的所有变量
Dim leibie As String '该读者的类别
Dim qixian As Integer '该读者可以借书的期限
Dim shumu As Integer '该读者已借书数量
Dim maxnum As Integer '该读者借书数量的限制
Private Sub Combo1_Click()
Combo2.ListIndex = Combo1.ListIndex
End Sub
Private Sub Combo2_Click()
Combo1.ListIndex = Combo2.ListIndex
End Sub
Private Sub Command1_Click()
Dim rs_borrowbook As New ADODB.Recordset
Dim sql As String
sql = "select * from 读者信息 where 读者编号='" & Combo1.Text & "'"
rs_borrowbook.Open sql, conn, adOpenKeyset, adLockPessimistic
leibie = rs_borrowbook.Fields(3)
shumu = rs_borrowbook.Fields(8)
rs_borrowbook.Close
sql = "select * from 读者类别 where 种类名称='" & leibie & "'"
rs_borrowbook.Open sql, conn, adOpenKeyset, adLockPessimistic
qixian = rs_borrowbook.Fields(2)
maxnum = rs_borrowbook.Fields(1)
rs_borrowbook.Close
If shumu >= maxnum Then
MsgBox "该读者借书数额已满!", vbOKOnly + vbExclamation
Exit Sub
End If
sql = "select * from 借阅信息"
rs_borrowbook.Open sql, conn, adOpenKeyset, adLockPessimistic
rs_borrowbook.AddNew
rs_borrowbook.Fields(1) = Combo1.Text
rs_borrowbook.Fields(2) = Combo2.Text
rs_borrowbook.Fields(3) = Label8.Caption
rs_borrowbook.Fields(4) = Label9.Caption
rs_borrowbook.Fields(5) = Date
rs_borrowbook.Fields(6) = DateAdd("Ww", qixian, Date)
rs_borrowbook.Update
rs_borrowbook.Close
sql = "select * from 书籍信息 where 书籍编号='" & book_num & "'"
rs_borrowbook.Open sql, conn, adOpenKeyset, adLockPessimistic
rs_borrowbook.Fields(7) = "是"
rs_borrowbook.Update
rs_borrowbook.Close
sql = "select * from 读者信息 where 读者编号='" & Combo1.Text & "'"
rs_borrowbook.Open sql, conn, adOpenKeyset, adLockPessimistic
rs_borrowbook.Fields(8) = rs_borrowbook.Fields(8) + 1
rs_borrowbook.Update
rs_borrowbook.Close
MsgBox "本书借阅成功!", vbOKOnly + vbExclamation
Unload Me
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Form_Load()
Dim rs_borrow As New ADODB.Recordset
Dim rs_reader As New ADODB.Recordset
Dim sql As String
sql = "select * from 书籍信息 where 书籍编号='" & book_num & "'"
rs_borrow.Open sql, conn, adOpenKeyset, adLockPessimistic
Label8.Caption = rs_borrow.Fields(0)
Label9.Caption = rs_borrow.Fields(1)
Label10.Caption = rs_borrow.Fields(2)
Label11.Caption = rs_borrow.Fields(3)
Label12.Caption = rs_borrow.Fields(4)
Label13.Caption = rs_borrow.Fields(5)
Label14.Caption = rs_borrow.Fields(6)
sql = "select * from 读者信息"
rs_reader.Open sql, conn, adOpenKeyset, adLockPessimistic
If Not rs_reader.EOF Then
Do While Not rs_reader.EOF
Combo1.AddItem rs_reader.Fields(1)
Combo2.AddItem rs_reader.Fields(0)
rs_reader.MoveNext
Loop
Else
MsgBox "请先登记读者!", vbOKOnly + vbExclamation
Exit Sub
End If
rs_borrow.Close
rs_reader.Close
End Sub 展开
1个回答
展开全部
Option Explicit 在模块级别中使用,强制显式声明模块中的所有变量
Dim leibie As String '该读者的类别
Dim qixian As Integer '该读者可以借书的期限
Dim shumu As Integer '该读者已借书数量
Dim maxnum As Integer '该读者借书数量的限制
Private Sub Combo1_Click()
Combo2.ListIndex = Combo1.ListIndex
End Sub
Private Sub Combo2_Click()
Combo1.ListIndex = Combo2.ListIndex
End Sub
Private Sub Command1_Click()
Dim rs_borrowbook As New ADODB.Recordset 打开借书数据表
Dim sql As String 定义spl 为数据型
sql = "select * from 读者信息 where 读者编号='" & Combo1.Text & "'" 从读者信息表中的读者编号栏寻找combo里选择的读者编号
rs_borrowbook.Open sql, conn, adOpenKeyset, adLockPessimistic
leibie = rs_borrowbook.Fields(3) 读取找到数据所在的类别行的数据
shumu = rs_borrowbook.Fields(8) 读取找到数据所在的数目行的数据
rs_borrowbook.Close 关闭
sql = "select * from 读者类别 where 种类名称='" & leibie & "'" 从读者类别表中的种类名称栏寻找leibie变量里的数据
rs_borrowbook.Open sql, conn, adOpenKeyset, adLockPessimistic 查找
qixian = rs_borrowbook.Fields(2) 读取找到数据所在的期限行的数据
maxnum = rs_borrowbook.Fields(1) 读取找到数据所在的目前该读者最多借书数行的数据
rs_borrowbook.Close 关闭
If shumu >= maxnum Then 判断目前借书数是否大于最多借书数,是则
MsgBox "该读者借书数额已满!", vbOKOnly + vbExclamation 提示借书已满
Exit Sub 退出整个过程
End If
sql = "select * from 借阅信息" 否则,打开借阅信息表
rs_borrowbook.Open sql, conn, adOpenKeyset, adLockPessimistic
rs_borrowbook.AddNew 添加新的数据
rs_borrowbook.Fields(1) = Combo1.Text 以下是将读者的信息输入
rs_borrowbook.Fields(2) = Combo2.Text
rs_borrowbook.Fields(3) = Label8.Caption
rs_borrowbook.Fields(4) = Label9.Caption
rs_borrowbook.Fields(5) = Date
rs_borrowbook.Fields(6) = DateAdd("Ww", qixian, Date)
rs_borrowbook.Update 更新
rs_borrowbook.Close 关闭
sql = "select * from 书籍信息 where 书籍编号='" & book_num & "'" 从书籍信息表中的书籍编号栏寻找图书标号的数据
rs_borrowbook.Open sql, conn, adOpenKeyset, adLockPessimistic
rs_borrowbook.Fields(7) = "是"
rs_borrowbook.Update
rs_borrowbook.Close
sql = "select * from 读者信息 where 读者编号='" & Combo1.Text & "'" 从读者信息表中的读者编号栏寻找combo的数据
rs_borrowbook.Open sql, conn, adOpenKeyset, adLockPessimistic
rs_borrowbook.Fields(8) = rs_borrowbook.Fields(8) + 1 往目前借书栏数目加1
rs_borrowbook.Update 更新
rs_borrowbook.Close
MsgBox "本书借阅成功!", vbOKOnly + vbExclamation 提示借书成功
Unload Me 关闭当前窗口
End Sub
Private Sub Command2_Click()
Unload Me 退出
End Sub
Private Sub Form_Load()
Dim rs_borrow As New ADODB.Recordset 连接借书表
Dim rs_reader As New ADODB.Recordset 连接读者表
Dim sql As String
sql = "select * from 书籍信息 where 书籍编号='" & book_num & "'" 从书籍信息表中的书籍编号栏寻找目前借书数的数据
rs_borrow.Open sql, conn, adOpenKeyset, adLockPessimistic
Label8.Caption = rs_borrow.Fields(0) 输出结果
Label9.Caption = rs_borrow.Fields(1)
Label10.Caption = rs_borrow.Fields(2)
Label11.Caption = rs_borrow.Fields(3)
Label12.Caption = rs_borrow.Fields(4)
Label13.Caption = rs_borrow.Fields(5)
Label14.Caption = rs_borrow.Fields(6)
sql = "select * from 读者信息" 读取读者信息表
rs_reader.Open sql, conn, adOpenKeyset, adLockPessimistic
If Not rs_reader.EOF Then 如果有该读者
Do While Not rs_reader.EOF
Combo1.AddItem rs_reader.Fields(1) 查找读者编号
Combo2.AddItem rs_reader.Fields(0) 查找读者姓名
rs_reader.MoveNext
Loop
Else
MsgBox "请先登记读者!", vbOKOnly + vbExclamation 如果没有该读者,提示登记
Exit Sub
End If
rs_borrow.Close 关闭表
rs_reader.Close 关闭表
End Sub
Dim leibie As String '该读者的类别
Dim qixian As Integer '该读者可以借书的期限
Dim shumu As Integer '该读者已借书数量
Dim maxnum As Integer '该读者借书数量的限制
Private Sub Combo1_Click()
Combo2.ListIndex = Combo1.ListIndex
End Sub
Private Sub Combo2_Click()
Combo1.ListIndex = Combo2.ListIndex
End Sub
Private Sub Command1_Click()
Dim rs_borrowbook As New ADODB.Recordset 打开借书数据表
Dim sql As String 定义spl 为数据型
sql = "select * from 读者信息 where 读者编号='" & Combo1.Text & "'" 从读者信息表中的读者编号栏寻找combo里选择的读者编号
rs_borrowbook.Open sql, conn, adOpenKeyset, adLockPessimistic
leibie = rs_borrowbook.Fields(3) 读取找到数据所在的类别行的数据
shumu = rs_borrowbook.Fields(8) 读取找到数据所在的数目行的数据
rs_borrowbook.Close 关闭
sql = "select * from 读者类别 where 种类名称='" & leibie & "'" 从读者类别表中的种类名称栏寻找leibie变量里的数据
rs_borrowbook.Open sql, conn, adOpenKeyset, adLockPessimistic 查找
qixian = rs_borrowbook.Fields(2) 读取找到数据所在的期限行的数据
maxnum = rs_borrowbook.Fields(1) 读取找到数据所在的目前该读者最多借书数行的数据
rs_borrowbook.Close 关闭
If shumu >= maxnum Then 判断目前借书数是否大于最多借书数,是则
MsgBox "该读者借书数额已满!", vbOKOnly + vbExclamation 提示借书已满
Exit Sub 退出整个过程
End If
sql = "select * from 借阅信息" 否则,打开借阅信息表
rs_borrowbook.Open sql, conn, adOpenKeyset, adLockPessimistic
rs_borrowbook.AddNew 添加新的数据
rs_borrowbook.Fields(1) = Combo1.Text 以下是将读者的信息输入
rs_borrowbook.Fields(2) = Combo2.Text
rs_borrowbook.Fields(3) = Label8.Caption
rs_borrowbook.Fields(4) = Label9.Caption
rs_borrowbook.Fields(5) = Date
rs_borrowbook.Fields(6) = DateAdd("Ww", qixian, Date)
rs_borrowbook.Update 更新
rs_borrowbook.Close 关闭
sql = "select * from 书籍信息 where 书籍编号='" & book_num & "'" 从书籍信息表中的书籍编号栏寻找图书标号的数据
rs_borrowbook.Open sql, conn, adOpenKeyset, adLockPessimistic
rs_borrowbook.Fields(7) = "是"
rs_borrowbook.Update
rs_borrowbook.Close
sql = "select * from 读者信息 where 读者编号='" & Combo1.Text & "'" 从读者信息表中的读者编号栏寻找combo的数据
rs_borrowbook.Open sql, conn, adOpenKeyset, adLockPessimistic
rs_borrowbook.Fields(8) = rs_borrowbook.Fields(8) + 1 往目前借书栏数目加1
rs_borrowbook.Update 更新
rs_borrowbook.Close
MsgBox "本书借阅成功!", vbOKOnly + vbExclamation 提示借书成功
Unload Me 关闭当前窗口
End Sub
Private Sub Command2_Click()
Unload Me 退出
End Sub
Private Sub Form_Load()
Dim rs_borrow As New ADODB.Recordset 连接借书表
Dim rs_reader As New ADODB.Recordset 连接读者表
Dim sql As String
sql = "select * from 书籍信息 where 书籍编号='" & book_num & "'" 从书籍信息表中的书籍编号栏寻找目前借书数的数据
rs_borrow.Open sql, conn, adOpenKeyset, adLockPessimistic
Label8.Caption = rs_borrow.Fields(0) 输出结果
Label9.Caption = rs_borrow.Fields(1)
Label10.Caption = rs_borrow.Fields(2)
Label11.Caption = rs_borrow.Fields(3)
Label12.Caption = rs_borrow.Fields(4)
Label13.Caption = rs_borrow.Fields(5)
Label14.Caption = rs_borrow.Fields(6)
sql = "select * from 读者信息" 读取读者信息表
rs_reader.Open sql, conn, adOpenKeyset, adLockPessimistic
If Not rs_reader.EOF Then 如果有该读者
Do While Not rs_reader.EOF
Combo1.AddItem rs_reader.Fields(1) 查找读者编号
Combo2.AddItem rs_reader.Fields(0) 查找读者姓名
rs_reader.MoveNext
Loop
Else
MsgBox "请先登记读者!", vbOKOnly + vbExclamation 如果没有该读者,提示登记
Exit Sub
End If
rs_borrow.Close 关闭表
rs_reader.Close 关闭表
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询