Foxtable(狐表)用户栏目专家坐堂 → 代码如何合并?


  共有3966人关注过本帖平板打印复制链接

主题:代码如何合并?

帅哥哟,离线,有人找我吗?
lgz518
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:五尾狐 帖子:1152 积分:7712 威望:0 精华:0 注册:2019/6/13 9:57:00
代码如何合并?  发帖心情 Post By:2022/5/20 18:09:00 [只看该作者]

第一部功能:

Dim c As String = e.Form.Controls("ComboBox1").Text
Dim d As String = " " & e.Form.Controls("ComboBox2").Text & " "

Dim filter As String
Dim 符号 As String
If d = " like " Then
    If tbl.Cols(c).IsString = False Then
        Tables("模糊查询_订单").filter = "convert(" & c & ",'System.String')" & d & "'%" & e.Form.Controls("TextBox1").Text & "%'"
    Else
        Tables("模糊查询_订单").filter = c & d & "'%" & e.Form.Controls("TextBox1").Text & "%'"
    End If
Else
    If tbl.Cols(c).IsString Then
        符号 = "'"
    ElseIf tbl.Cols(c).IsDate Then
        符号 = "#"
        
    End If
    
  Tables("模").filter = c & d & 符号 & e.Form.Controls("TextBox1").Text & 符号
    
End If

    第二部功能
    
    Dim Filter As String
    With e.Form.Controls("StartDate")
        If .Value IsNot Nothing Then
            If Filter > "" Then
                Filter = Filter & " And "
            End If
            Filter = Filter & "日期 >= #" & .Value & "#"
        End If
    End With
    With e.Form.Controls("EndDate")
        If .Value IsNot Nothing Then
            If Filter > "" Then
               Filter = Filter & " And "
            End If
            Filter = Filter & "日期 <= #" & .Value & "#"
        End If
    End With
    
    Tables("模糊查询_订单").Filter = Filter 

问题一:上面代码,第一部和第二部分开使用是可以,现在如何实现合并在一起?

我试着做下面代码,报错提示缺少运算?

Dim tbl As Table = Tables("订单")
Dim c As String = e.Form.Controls("ComboBox1").Text
Dim d As String = " " & e.Form.Controls("ComboBox2").Text & " "

Dim d1 As String = e.Form.Controls("StartDate").Text
Dim d2 As String = e.Form.Controls("EndDate").Text

Dim filter As String
Dim 符号 As String
If d = " like " Then
    If tbl.Cols(c).IsString = False Then
        Tables("模糊查询_订单").filter = "convert(" & c & ",'System.String')" & d & "'%" & e.Form.Controls("TextBox1").Text & "%'"
    Else
        Tables("模糊查询_订单").filter = c & d & "'%" & e.Form.Controls("TextBox1").Text & "%'"
    End If
Else
    If tbl.Cols(c).IsString Then
        符号 = "'"
    ElseIf tbl.Cols(c).IsDate Then
        符号 = "#"
        d1 = "#"
        d2 = "#"
    End If
    Tables("订单").filter = c & d & d1 & d2 & 符号 & e.Form.Controls("TextBox1").Text & 符号
'    Tables("查询").filter = c & d & 符号 & e.Form.Controls("TextBox1").Text & 符号
    
End If

[此贴子已经被作者于2022/5/21 21:35:09编辑过]

 回到顶部
总数 22 1 2 3 下一页