一段vb程序,哪位高手给看看错在哪
If Text(0).Text = "" Then
MsgBox "请输入至少一个查询条件,或把查询条件输入在前面的行上!", vbOKOnly + vbInformation, "注意"
Text(0).SetFocus
Text(1).Text = ""
Exit Sub
End If
For i = 0 To 1
If Not Text(i).Text = "" And Not Combo(3 * i).ListIndex = 3 And Not Combo(3 * i).ListIndex = 1 And Not Combo(3 * i + 1).ListIndex = 0 Then
MsgBox "该字段的查询关系不能为>或<!", vbOKOnly + vbInformation, "注意"
Combo(3 * i + 1).SetFocus
Exit Sub
End If
Next i
query = True
Dim j As Integer
For j = 0 To 1
If Combo(3 * j + 1) = "等于" Then
Combo(3 * j + 1) = "="
'Combo(3 * j + 1).ListIndex = 0
End If
Next
For j = 0 To 1
If Not Text(j).Text = "" Then
If Combo(3 * j).ListIndex = 3 Or Combo(3 * j).ListIndex = 1 Then
If j = 0 Then
SQL = "select * from 工程信息 where " & Combo(3 * j).Text & Combo(3 * j + 1).Text & CStr(Text(j).Text)
Else
SQL = SQL & "" & Combo(3 * j - 1).Text & "" & Combo(3 * j).Text & Combo(3 * j + 1) & Text(j).Text
End If
Else
If j = 0 Then
SQL = "select * from 工程信息 where " & Combo(3 * j).Text & Combo(3 * j + 1).Text & "'" & Text(j).Text & "'"
Else
SQL = SQL & Combo(3 * j - 1).Text & "" & Combo(3 * j).Text & Combo(3 * j + 1) & "'" & Text(j).Text & "'"
End If
End If
End If
Next j
MsgBox ""
gado.ConnectionString = gConnectionString
gado.RecordSource = SQL
gado.Refresh
Set DataGrid1.DataSource = gado
参考答案:Combo控件组是如何命名的?
看你的程序好像是Combo(0)、Combo(3)、Combo(6).....