有谁能帮我解释下这些VB代码啊

来源:百度知道 编辑:UC知道 时间:2024/09/24 13:49:37
很急急,大家能不能帮我看下,论文里要写的,谢谢啊,给我重要的给我解释下,好了,谢谢大家,今天就要交了

Private Sub Command3_Click()
Dim j As Long
Dim txtSQL As String
Dim txSQL As String
txtSQL = "select * from score_Form"
If Text2(1) <> "" Then
txtSQL = txtSQL & " where score_Per='" & Trim(Text2(1)) & "'"
End If
If Combo2(0).Text <> "" Then
If txtSQL = "select * from score_Form" Then
txtSQL = txtSQL & " where score_Cla='" & Trim(Combo2(0).Text) & "'"
Else
txtSQL = txtSQL & " And score_Cla='" & Trim(Combo2(0).Text) & "'"
End If
End If
If Combo2(1).Text <> "" Then
If txtSQL = "select * from score_Form" Then
txtSQL = txtSQL & " where score_Stu='" & Trim(Combo2(1

'把主要的代码,给你注释了一下

Private Sub Command3_Click()
Dim j As Long
Dim txtSQL As String
Dim txSQL As String

'从这儿开始,是动态生成SQL语句,根据你的输入不同,SQL语句的结构也不同
txtSQL = "select * from score_Form"
If Text2(1) <> "" Then
txtSQL = txtSQL & " where score_Per='" & Trim(Text2(1)) & "'"
End If
If Combo2(0).Text <> "" Then
If txtSQL = "select * from score_Form" Then
txtSQL = txtSQL & " where score_Cla='" & Trim(Combo2(0).Text) & "'"
Else
txtSQL = txtSQL & " And score_Cla='" & Trim(Combo2(0).Text) & "'"
End If
End If
If Combo2(1).Text <> "" Then
If txtSQL = "select * from score_Form" Then
txtSQL = txtSQL & " where score_Stu=&