Foxtable(狐表)用户栏目专家坐堂 → 请大神指教 计算优化


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

主题:请大神指教 计算优化

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


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2017/11/19 21:01:00 [只看该作者]

参考代码

 

MainTable = Tables("统计")

Dim wlbm As String = "17475000011232"

e.Form.Controls("Label1").Text = "正在处理数据..."
Application.DoEvents()

Dim drs = DataTables("sum").Select("物料编码='" & wlbm & "' and 日期时间 <= #" & Date.Today.AddDays(3) & "# and 日期时间 > #" & Date.Today & "#  ", "日期时间")
Dim p As WinForm.ProgressBar
p = e.Form.Controls("ProgressBar1")
p.Maximum = drs.Count  '设置最大值
p.Minimum = 0 '设置最小值
p.Value = 0 '设置当前值

DataTables("统计").ResumeRedraw
DataTables("统计").StopRedraw
Dim st As Date = Date.Now '将开始时间保存在变量st中
Dim sum = DataTables("sum").compute("sum(需求数量)", "物料编码='" & wlbm & "' and 日期时间 <= #" & Date.Today & "#")
For Each dr As DataRow In drs
    Dim dr1 As DataRow = DataTables("统计").AddNew()
   
    dr1("物料编码") = dr("物料编码")
    dr1("日期时间") = dr("日期时间")
    Dim temp As Double = sum
    For Each dr2 As DataRow In drs
        If dr2("日期时间") <= dr1("日期时间") Then
            temp += dr2("需求数量")
        Else
            Exit For
        End If
    Next
    dr1("在此之前的需求数量") = temp
   
    p.Value += 1 '当前值为已经完成的行数
Next

DataTables("统计").ResumeRedraw


If DataTables("统计").HasChanges Then
    'DataTables("统计").save
End If

e.Form.Controls("Label1").Text = " 更新完毕."

MessageBox.Show("耗时: " & (Date.Now - st).TotalSeconds & "秒") '计算并显示执行代码所花费的秒数


 回到顶部