如何拼条件VB?

来源:百度知道 编辑:UC知道 时间:2024/05/18 06:27:21
如何拼条件VB?谢谢了,非常感谢

Public Function sql_str() As String
Dim ht As String
Dim rq1 As String
Dim rq2 As String
Dim gg As String
If Trim(Me.txhtcx.Text) <> "" Then
ht = " and 合同号" & Combo1(0).Text & "'" & txhtcx.Text & "'"
End If
If Trim(Me.Text1.Text) <> "" Then
rq1 = " and 日期>'" & Text1.Text & "'"
End If
If Trim(Me.Text3.Text) <> "" Then
rq2 = " and 日期<'" & Text3.Text & "'"
End If
If Trim(Me.Text2.Text) <> "" Then
gg = " and 型号规格" & Combo1(2).Text & "'" & Text2.Text & "'"
End If

sql_str = ht & rq1 & rq2 & gg

End Function