以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  [求助]用动态生成的字符串代替表达式,为啥总是差点火候?  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=110267)

--  作者:zyl19810322
--  发布时间:2017/11/30 9:06:00
--  [求助]用动态生成的字符串代替表达式,为啥总是差点火候?
Dim jbxx As DataTable = DataTables("基本信息")
Dim wfcl As DataTable = DataTables("违法及处理情况")
Dim cfyj As DataTable = DataTables("处罚依据")
Dim fltw As DataTable = DataTables("法律条文")
    Dim drs As List(Of DataRow)
    drs = wfcl.Select("案件编号 = \'" & jbxx.DataRows(0)("案件编号") & "\'")
    Dim y As String = ""
    For Each dr As DataRow In drs
        Dim wfs As List(of DataRow)
        wfs = cfyj.Select("违法事实 = \'" & dr("违法事实") & "\'")
        For Each wf As DataRow In wfs
            y &= "[法律条文编码] = """ & wf("法律条文编码") & """ OrElse "
        Next
    Next
    Dim fts As List(of DataRow)
    fts = fltw.Select(y.TrimEnd(" ","O","r","E","l","s","e"),"序号")

图片点击可在新窗口打开查看此主题相关图片如下:动态表达式错误.png
图片点击可在新窗口打开查看


--  作者:zyl19810322
--  发布时间:2017/11/30 9:07:00
--  
            y &= "[法律条文编码] = """ & wf("法律条文编码") & """ OrElse "
这条代码有什么问题吗?

--  作者:有点甜
--  发布时间:2017/11/30 9:30:00
--  
Dim jbxx As DataTable = DataTables("基本信息")
Dim wfcl As DataTable = DataTables("违法及处理情况")
Dim cfyj As DataTable = DataTables("处罚依据")
Dim fltw As DataTable = DataTables("法律条文")
Dim drs As List(Of DataRow)
drs = wfcl.Select("案件编号 = \'" & jbxx.DataRows(0)("案件编号") & "\'")
Dim y As String = "1=2"
For Each dr As DataRow In drs
    Dim wfs As List(of DataRow)
    wfs = cfyj.Select("违法事实 = \'" & dr("违法事实") & "\'")
    For Each wf As DataRow In wfs
        y &= " or [法律条文编码] = \'" & wf("法律条文编码") & "\'"
    Next
Next
msgbox(y)
Dim fts As List(of DataRow)
fts = fltw.Select(y,"序号")

--  作者:zyl19810322
--  发布时间:2017/11/30 13:15:00
--  
Dim y As String = "1=2"
这句有什么意义?


--  作者:有点甜
--  发布时间:2017/11/30 14:33:00
--  
以下是引用zyl19810322在2017/11/30 13:15:00的发言:
Dim y As String = "1=2"
这句有什么意义?

 

没有意义,就是为了和 or 连接,这样就不用删除最前或者最后面的 or