成语大全网 - 汉语词典 - vb 代码 逐句翻译一下 谢谢

vb 代码 逐句翻译一下 谢谢

Private Sub Command1_Click() '单击按钮1

Dim rs_findreader As New ADODB.Recordset '定义一个数据结果集

Dim sql As String '定义存储sql语句的变量

If Check1.Value = vbChecked Then '如果复选框check1被选中,sql语句中读者编号等于text1的值

sql = "读者编号='" & Trim(Text1.Text & " ") & "'"

End If

If Check2.Value = vbChecked Then '同上

If Trim(sql) = "" Then

sql = "读者姓名='" & Trim(Text2.Text & " ") & "'"

Else

sql = sql & "and 读者姓名='" & Trim(Text2.Text & " ") & "'"

End If

End If

If Check3.Value = vbChecked Then '同上

If Trim(sql) = "" Then

sql = "读者类别='" & Trim(Combo1.Text & " ") & "'"

Else

sql = sql & "and 读者类别='" & Trim(Combo1.Text & " ") & "'"

End If

End If

sql = "select * from 读者信息 where " & sql '最后补全sql语句

rs_findreader.CursorLocation = adUseClient

rs_findreader.Open sql, conn, adOpenKeyset, adLockPessimistic '打开数据库连接,执行sql语句

DataGrid1.AllowAddNew = False '数据集不允许添加

DataGrid1.AllowDelete = False '数据集不允许删除

DataGrid1.AllowUpdate = False '数据集不允许修改

Set DataGrid1.DataSource = rs_findreader '在datagrid中显示数据

'rs_findreader.Close '关闭数据库连接

End Sub

Private Sub Command2_Click()

Unload Me '程序退出

End Sub

Private Sub Form_Load() '窗口加载时填充combo1

Dim rs_find As New ADODB.Recordset

Dim sql As String

sql = "select * from 读者类别"

rs_find.Open sql, conn, adOpenKeyset, adLockPessimistic

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