以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  条件可否引用字符串?  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=55685)

--  作者:luodang2050
--  发布时间:2014/8/21 12:31:00
--  条件可否引用字符串?

如题,设置条件为 i > 0 , 在某一情况下,又得设置为 i < 0 , 

现想把条件存到某一string变量j里面(j=">0"),通过类似 i & j 调用, 能否实现类似功能?


--  作者:luodang2050
--  发布时间:2014/8/21 12:54:00
--  

想到了此种动态编译的方法,不知还有没更好方法?

Dim Code As String          
                Code = "Dim n As Integer = " & n & vbcrlf
                Code = Code & "return " & tr("添加条件")
                Functions.remove("动态比较")
                Functions.Add("动态比较",Code)
                Functions.Complie()                     
                If Functions.Execute("动态比较")

                    Forms(导航窗口).Controls(任务栏).Pages(tr("页面索引")).links.Add(tr("任务ID"),n & "_" & tr("任务名"))
                End If


--  作者:有点甜
--  发布时间:2014/8/21 13:28:00
--  
 如果判断不多,就尽量把代码写死,具体提问题,实例说明。