openrs strsql
For i = 0 To rs.Fields.Count - 1
Combo1(4).AddItem rs.Fields(i).Name
Next i
closers
closecn
' ----------------------初始化Combo1(2)
With Combo1(2)
.AddItem " = "
.AddItem " > "
.AddItem " < "
.AddItem " >= "
.AddItem " <= "
.AddItem " <> "
.AddItem " like "
End With
' -----设置Combo1的0--3各元素与Grid1的0--3各列的宽度相同
Combo1(0).Width = 1000
Combo1(1).Width = 1850
Combo1(2).Width = 1000
Combo1(3).Width = 2500
End Sub
4.取消按钮的单击事件
Private Sub Cmd_cancel_Click()
Unload Me
End Sub
5.确定按钮的单击事件
Private Sub Cmd_confirm_Click()
Dim i As Integer
' -----根据Combo1(3)的特殊值,修改Grid1当前单元的文本
If Combo1(3).Visible = True Then
If Combo1(3).Text = "True" Then
Grid1.TextMatrix(Grid1.Row, 3) = "1"
ElseIf Combo1(3).Text = "Flase" Then
Grid1.TextMatrix(Grid1.Row, 3) = "0"
Else
Grid1.TextMatrix(Grid1.Row, 3) = Combo1(3).Text
End If
End If
strcondition = ""
' -----根据不同的关系运算,给strcondition变量赋值
If Grid1.Rows >= 2 And Grid1.TextMatrix(1, 1) <> "" Then
If Grid1.TextMatrix(1, 2) = " like " Then
strcondition = " where " & Grid1.TextMatrix(1, 4) & " like " & "'%" & Grid1.TextMatrix(1, 3) & "%'"
Else
strcondition = " where " & Grid1.TextMatrix(1, 4) & Grid1.TextMatrix(1, 2) & "'" & Grid1.TextMatrix(1, 3) & "'"
End If
For i = 2 To Grid1.Rows - 1
If Grid1.TextMatrix(i, 2) = " like " Then
strcondition = strcondition & Grid1.TextMatrix(i, 0) & Grid1.TextMatrix(i, 4) & " like " & "'%" & Grid1.TextMatrix(i, 3) & "%'"
Else
strcondition = strcondition & Grid1.TextMatrix(i, 0) & Grid1.TextMatrix(i, 4) & Grid1.TextMatrix(i, 2) & "'" & Grid1.TextMatrix(i, 3) & "'"
End If
|