以文本方式查看主题

-  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=158148)

--  作者:天一生水
--  发布时间:2020/11/9 21:17:00
--  [求助]为临时列循环赋值

老师好!

为统计表的5个临时列循环行、赋值,非常慢,是不是代码写的有问题?

 


图片点击可在新窗口打开查看此主题相关图片如下:截屏图片 (3).jpg
图片点击可在新窗口打开查看 

 

 

For Each r As Row In Tables("批量选股_table10").Rows    ’窗口表循环行
    If r("日期") <= Date.Today Then
        Dim dr1 As DataRow
        dr1 = DataTables("股票日线").SQLFind("代码 = \'999999\' and 日期 = \'" & r("日期") & "\'")
        If dr1 IsNot Nothing
        r("上证指数") = dr1("涨跌幅")
        End If
       
        Dim dr2 As DataRow
        dr2 = DataTables("股票日线").SQLFind("代码 = \'399001\' and 日期 = \'" & r("日期") & "\'")
        If dr2 IsNot Nothing
            r("深圳成指") = dr2("涨跌幅")
        End If
       
        Dim dr3 As DataRow
        dr3 = DataTables("股票日线").SQLFind("代码 = \'399005\' and 日期 = \'" & r("日期") & "\'")
        If dr3 IsNot Nothing
        r("中小板指") = dr3("涨跌幅")
        End If
       
        Dim dr4 As DataRow
        dr4 = DataTables("股票日线").SQLFind("代码 = \'399006\' and 日期 = \'" & r("日期") & "\'")
        If dr4 IsNot Nothing
        r("创业板指") = dr4("涨跌幅")
        End If
       
        Dim dr5 As DataRow
        dr5 = DataTables("股票日线").SQLFind("代码 = \'399106\' and 日期 = \'" & r("日期") & "\'")
        If dr5 IsNot Nothing
        r("深圳综指") = dr5("涨跌幅")
        End If
    End If
Next


[此贴子已经被作者于2020/11/9 21:17:53编辑过]

--  作者:有点蓝
--  发布时间:2020/11/9 21:42:00
--  
从窗口表里获取最大日期和最小日期,把上面几个代码的数据一次性加载处理,SQLFind改Find