以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  代码报错,求大神指教  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=63486)

--  作者:nclo
--  发布时间:2015/1/21 22:58:00
--  代码报错,求大神指教
Dim xmtz As WinForm.TextBox = e.Form.Controls("所在地区")
Dim kgnf As WinForm.TextBox = e.Form.Controls("资金文号")
Dim afbc As WinForm.TextBox = e.Form.Controls("类别")
Dim rtyu As WinForm.TextBox = e.Form.Controls("名称")
Dim frip As WinForm.TextBox = e.Form.Controls("年度")
Dim Filter As String Or Integer
If xmtz.Value IsNot Nothing Then
        Filter = "第一列 like \'*" & xmtz.Value & "*\'"
     End If
If kgnf.Value IsNot Nothing Then
        If Filter > "" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "第二列 or 第三列 like \'*" & kgnf.Value & "*\'"
    End If
If afbc.Value IsNot Nothing Then
        If Filter > "" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "第四列 like \'*" & afbc.Value & "*\'"
    End If
If rtyu.Value IsNot Nothing Then
        If Filter > "" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "第五列 like \'*" & rtyu.Value & "*\'"
    End If
If frip.Value IsNot Nothing Then
        If Filter > "" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "第六列 like \'*" & rtyu.Value & "*\'"
    End If
If Filter> "" Then
    Tables("表C").Filter = Filter
    End If




Dim Filter As String Or Integer报错说应为语句结束。求大神指教

--  作者:有点甜
--  发布时间:2015/1/21 23:57:00
--  

呃,

 

Dim Filter As String Or Integer

 

改成

 

Dim Filter As String


--  作者:nclo
--  发布时间:2015/1/22 7:52:00
--  
Dim frip As WinForm.TextBox = e.Form.Controls("年度")

甜老师,但这一个列是整数型,日期。

--  作者:Bin
--  发布时间:2015/1/22 7:56:00
--  
If frip.Value IsNot Nothing Then
        If Filter > "" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "第六列 = \'#" & rtyu.Value & "#\'"
    End If

--  作者:nclo
--  发布时间:2015/1/22 8:51:00
--  
感谢两位版主大神!!If kgnf.Value IsNot Nothing Then
        If Filter > "" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "第二列 or 第三列 like \'*" & kgnf.Value & "*\'"
    End If这里的代码可否改造为If kgnf.Value IsNot Nothing Then
        If Filter > "" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "第二列 or 第三列 like \'*"  \'#"& kgnf.Value & "*\'" "#\'"

因为第二列或者第三列为字符列,但搜索内容和内容有数字。

--  作者:Bin
--  发布时间:2015/1/22 8:54:00
--  
只要是字符型列就当作字符串使用即可

5楼代码不可以这么写


--  作者:nclo
--  发布时间:2015/1/22 8:55:00
--  
又出现新问题,在年度的TEXTBOX输入一个年度数字,点击搜索,出来无法在 System.DateTime 和 System.String 上执行“Like”操作。
--  作者:Bin
--  发布时间:2015/1/22 8:56:00
--  
If frip.Value IsNot Nothing Then
        If Filter > "" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "第六列 = #" & rtyu.Value & "#"
    End If

--  作者:有点甜
--  发布时间:2015/1/22 8:59:00
--  
If frip.Value IsNot Nothing Then
    If Filter > "" Then
        Filter = Filter & " And "
    End If
    Filter = Filter & "Convert(第六列,\'System.String\') Like \'%" & rtyu.Value & "%\'"
End If

--  作者:nclo
--  发布时间:2015/1/22 8:59:00
--  
BIN老师,已经按您的代码改造,表达式包含无效的日期常量“##”