vb 代码 帮忙翻译一下 越详细越好···· 谢谢··
PrivateSubCommand1_Click()Dimrs_findbookAsNewADODB.RecordsetDimsqlAsStringIfCheck1.Va...
Private Sub Command1_Click()
Dim rs_findbook As New ADODB.Recordset
Dim sql As String
If Check1.Value = vbChecked Then
sql = "书名='" & Trim(Text1.Text & " ") & "'"
End If
If Check2.Value = vbChecked Then
If Trim(sql) = "" Then
sql = "类别='" & Trim(Combo1.Text & " ") & "'"
Else
sql = sql & "and 书名='" & Trim(Combo1.Text & " ") & "'"
End If
End If
If Check3.Value = vbChecked Then
If Trim(sql) = "" Then
sql = "作者='" & Trim(Text2.Text & " ") & "'"
Else
sql = sql & "and 作者='" & Trim(Text2.Text & " ") & "'"
End If
End If
If Check4.Value = vbChecked Then
If Trim(sql) = "" Then
sql = "出版社='" & Trim(Text3.Text & " ") & "'"
Else
sql = sql & "and 出版社='" & Trim(Text3.Text & " ") & "'"
End If
End If
If Check5.Value = vbChecked Then
If Trim(sql) = "" Then
sql = "书籍编号='" & Trim(Text4.Text & " ") & "'"
Else
sql = sql & "and 书籍编号='" & Trim(Text4.Text & " ") & "'"
End If
End If
If Trim(sql) = "" Then
MsgBox "请选择查询方式!", vbOKOnly + vbExclamation
Exit Sub
End If
sql = "select * from 书籍信息 where " & sql
rs_findbook.CursorLocation = adUseClient
rs_findbook.Open sql, conn, adOpenKeyset, adLockPessimistic
DataGrid1.AllowAddNew = False
DataGrid1.AllowDelete = False
DataGrid1.AllowUpdate = False
Set DataGrid1.DataSource = rs_findbook
'rs_findbook.Close
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Command3_Click()
If Trim(book_num) = "" Then
MsgBox "请选择要借阅的图书!", vbOKOnly + vbExclamation
Exit Sub
End If
If panduan = "是" Then
MsgBox "此书已被借出!", vbOKOnly + vbExclamation
Exit Sub
End If
frmborrowbook.Show
End Sub
Private Sub DataGrid1_RowColChange(LastRow As Variant, ByVal LastCol As Integer)
book_num = DataGrid1.Columns(0).CellValue(DataGrid1.Bookmark)
panduan = DataGrid1.Columns(7).CellValue(DataGrid1.Bookmark)
End Sub
Private Sub Form_Load()
Dim rs_find As New ADODB.Recordset
Dim sql As String
sql = "select * from 图书类别"
rs_find.Open sql, conn, adOpenKeyset, adLockPessimistic
rs_find.MoveFirst
If Not rs_find.EOF Then
Do While Not rs_find.EOF
Combo1.AddItem rs_find.Fields(0)
rs_find.MoveNext
Loop
Combo1.ListIndex = 0
End If
rs_find.Close
End Sub 展开
Dim rs_findbook As New ADODB.Recordset
Dim sql As String
If Check1.Value = vbChecked Then
sql = "书名='" & Trim(Text1.Text & " ") & "'"
End If
If Check2.Value = vbChecked Then
If Trim(sql) = "" Then
sql = "类别='" & Trim(Combo1.Text & " ") & "'"
Else
sql = sql & "and 书名='" & Trim(Combo1.Text & " ") & "'"
End If
End If
If Check3.Value = vbChecked Then
If Trim(sql) = "" Then
sql = "作者='" & Trim(Text2.Text & " ") & "'"
Else
sql = sql & "and 作者='" & Trim(Text2.Text & " ") & "'"
End If
End If
If Check4.Value = vbChecked Then
If Trim(sql) = "" Then
sql = "出版社='" & Trim(Text3.Text & " ") & "'"
Else
sql = sql & "and 出版社='" & Trim(Text3.Text & " ") & "'"
End If
End If
If Check5.Value = vbChecked Then
If Trim(sql) = "" Then
sql = "书籍编号='" & Trim(Text4.Text & " ") & "'"
Else
sql = sql & "and 书籍编号='" & Trim(Text4.Text & " ") & "'"
End If
End If
If Trim(sql) = "" Then
MsgBox "请选择查询方式!", vbOKOnly + vbExclamation
Exit Sub
End If
sql = "select * from 书籍信息 where " & sql
rs_findbook.CursorLocation = adUseClient
rs_findbook.Open sql, conn, adOpenKeyset, adLockPessimistic
DataGrid1.AllowAddNew = False
DataGrid1.AllowDelete = False
DataGrid1.AllowUpdate = False
Set DataGrid1.DataSource = rs_findbook
'rs_findbook.Close
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Command3_Click()
If Trim(book_num) = "" Then
MsgBox "请选择要借阅的图书!", vbOKOnly + vbExclamation
Exit Sub
End If
If panduan = "是" Then
MsgBox "此书已被借出!", vbOKOnly + vbExclamation
Exit Sub
End If
frmborrowbook.Show
End Sub
Private Sub DataGrid1_RowColChange(LastRow As Variant, ByVal LastCol As Integer)
book_num = DataGrid1.Columns(0).CellValue(DataGrid1.Bookmark)
panduan = DataGrid1.Columns(7).CellValue(DataGrid1.Bookmark)
End Sub
Private Sub Form_Load()
Dim rs_find As New ADODB.Recordset
Dim sql As String
sql = "select * from 图书类别"
rs_find.Open sql, conn, adOpenKeyset, adLockPessimistic
rs_find.MoveFirst
If Not rs_find.EOF Then
Do While Not rs_find.EOF
Combo1.AddItem rs_find.Fields(0)
rs_find.MoveNext
Loop
Combo1.ListIndex = 0
End If
rs_find.Close
End Sub 展开
2个回答
展开全部
Private Sub Command1_Click() 'Command1的功能就是从界面获得查询条件,查询结果再返回给界面
Dim rs_findbook As New ADODB.Recordset
Dim sql As String
If Check1.Value = vbChecked Then '这五个if都是可以选择输入的条件,当有条件的时候就拼到where条件里
sql = "书名='" & Trim(Text1.Text & " ") & "'"
End If
If Check2.Value = vbChecked Then
If Trim(sql) = "" Then
sql = "类别='" & Trim(Combo1.Text & " ") & "'"
Else
sql = sql & "and 书名='" & Trim(Combo1.Text & " ") & "'"
End If
End If
If Check3.Value = vbChecked Then
If Trim(sql) = "" Then
sql = "作者='" & Trim(Text2.Text & " ") & "'"
Else
sql = sql & "and 作者='" & Trim(Text2.Text & " ") & "'"
End If
End If
If Check4.Value = vbChecked Then
If Trim(sql) = "" Then
sql = "出版社='" & Trim(Text3.Text & " ") & "'"
Else
sql = sql & "and 出版社='" & Trim(Text3.Text & " ") & "'"
End If
End If
If Check5.Value = vbChecked Then
If Trim(sql) = "" Then
sql = "书籍编号='" & Trim(Text4.Text & " ") & "'"
Else
sql = sql & "and 书籍编号='" & Trim(Text4.Text & " ") & "'"
End If
End If
If Trim(sql) = "" Then '判断有没有输入查询条件,没有就提示。
MsgBox "请选择查询方式!", vbOKOnly + vbExclamation
Exit Sub
End If
sql = "select * from 书籍信息 where " & sql
rs_findbook.CursorLocation = adUseClient
rs_findbook.Open sql, conn, adOpenKeyset, adLockPessimistic '通过open函数连接数据库获得数据集
DataGrid1.AllowAddNew = False '这三个是不允许通过DataGrid1增删改
DataGrid1.AllowDelete = False
DataGrid1.AllowUpdate = False
Set DataGrid1.DataSource = rs_findbook
'rs_findbook.Close 'rs_findbook是数据集,他的释放是:set rs_findbook = nothing(必须要有,否则时间多次操作会很浪费资源)
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Command3_Click()
If Trim(book_num) = "" Then '如果book_num是空则提示
MsgBox "请选择要借阅的图书!", vbOKOnly + vbExclamation
Exit Sub
End If
If panduan = "是" Then '如果panduan是“是”则提示
MsgBox "此书已被借出!", vbOKOnly + vbExclamation
Exit Sub
End If
frmborrowbook.Show '显示frmborrowbook
End Sub
Private Sub DataGrid1_RowColChange(LastRow As Variant, ByVal LastCol As Integer) '你这个地方应该是不对的吧,只有列,没指定是哪一行啊,而且看你传的参数也是有行的,所以你这个地方获得的值应该是不准确的
book_num = DataGrid1.Columns(0).CellValue(DataGrid1.Bookmark) '把界面获得的第一列赋值给book_num
panduan = DataGrid1.Columns(7).CellValue(DataGrid1.Bookmark) '把界面获得的第七列赋值给panduan
End Sub
Private Sub Form_Load()
Dim rs_find As New ADODB.Recordset
Dim sql As String
sql = "select * from 图书类别"
rs_find.Open sql, conn, adOpenKeyset, adLockPessimistic
rs_find.MoveFirst
If Not rs_find.EOF Then '如果图书类别表里有内容则执行if里的语句
Do While Not rs_find.EOF
Combo1.AddItem rs_find.Fields(0) '把图书类别表的第一个字段添加到Combo1里
rs_find.MoveNext
Loop
Combo1.ListIndex = 0
End If
rs_find.Close 'rs_find是数据集,他的释放是:set rs_find = nothing
End Sub
明天上不了网,再有问题后天问吧
Dim rs_findbook As New ADODB.Recordset
Dim sql As String
If Check1.Value = vbChecked Then '这五个if都是可以选择输入的条件,当有条件的时候就拼到where条件里
sql = "书名='" & Trim(Text1.Text & " ") & "'"
End If
If Check2.Value = vbChecked Then
If Trim(sql) = "" Then
sql = "类别='" & Trim(Combo1.Text & " ") & "'"
Else
sql = sql & "and 书名='" & Trim(Combo1.Text & " ") & "'"
End If
End If
If Check3.Value = vbChecked Then
If Trim(sql) = "" Then
sql = "作者='" & Trim(Text2.Text & " ") & "'"
Else
sql = sql & "and 作者='" & Trim(Text2.Text & " ") & "'"
End If
End If
If Check4.Value = vbChecked Then
If Trim(sql) = "" Then
sql = "出版社='" & Trim(Text3.Text & " ") & "'"
Else
sql = sql & "and 出版社='" & Trim(Text3.Text & " ") & "'"
End If
End If
If Check5.Value = vbChecked Then
If Trim(sql) = "" Then
sql = "书籍编号='" & Trim(Text4.Text & " ") & "'"
Else
sql = sql & "and 书籍编号='" & Trim(Text4.Text & " ") & "'"
End If
End If
If Trim(sql) = "" Then '判断有没有输入查询条件,没有就提示。
MsgBox "请选择查询方式!", vbOKOnly + vbExclamation
Exit Sub
End If
sql = "select * from 书籍信息 where " & sql
rs_findbook.CursorLocation = adUseClient
rs_findbook.Open sql, conn, adOpenKeyset, adLockPessimistic '通过open函数连接数据库获得数据集
DataGrid1.AllowAddNew = False '这三个是不允许通过DataGrid1增删改
DataGrid1.AllowDelete = False
DataGrid1.AllowUpdate = False
Set DataGrid1.DataSource = rs_findbook
'rs_findbook.Close 'rs_findbook是数据集,他的释放是:set rs_findbook = nothing(必须要有,否则时间多次操作会很浪费资源)
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Command3_Click()
If Trim(book_num) = "" Then '如果book_num是空则提示
MsgBox "请选择要借阅的图书!", vbOKOnly + vbExclamation
Exit Sub
End If
If panduan = "是" Then '如果panduan是“是”则提示
MsgBox "此书已被借出!", vbOKOnly + vbExclamation
Exit Sub
End If
frmborrowbook.Show '显示frmborrowbook
End Sub
Private Sub DataGrid1_RowColChange(LastRow As Variant, ByVal LastCol As Integer) '你这个地方应该是不对的吧,只有列,没指定是哪一行啊,而且看你传的参数也是有行的,所以你这个地方获得的值应该是不准确的
book_num = DataGrid1.Columns(0).CellValue(DataGrid1.Bookmark) '把界面获得的第一列赋值给book_num
panduan = DataGrid1.Columns(7).CellValue(DataGrid1.Bookmark) '把界面获得的第七列赋值给panduan
End Sub
Private Sub Form_Load()
Dim rs_find As New ADODB.Recordset
Dim sql As String
sql = "select * from 图书类别"
rs_find.Open sql, conn, adOpenKeyset, adLockPessimistic
rs_find.MoveFirst
If Not rs_find.EOF Then '如果图书类别表里有内容则执行if里的语句
Do While Not rs_find.EOF
Combo1.AddItem rs_find.Fields(0) '把图书类别表的第一个字段添加到Combo1里
rs_find.MoveNext
Loop
Combo1.ListIndex = 0
End If
rs_find.Close 'rs_find是数据集,他的释放是:set rs_find = nothing
End Sub
明天上不了网,再有问题后天问吧
2011-11-13
展开全部
凭啥伺候这种傻子啊
更多追问追答
追问
20份
追答
20分算个狗屁,能买几个馒头?
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询