以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- [求助]Find查找范围 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=81078) |
-- 作者:dixiaxiaodan -- 发布时间:2016/2/18 9:35:00 -- [求助]Find查找范围 find能够设置查找范围吗?比如只当前位置以上n行的数据内进行条件查找 |
-- 作者:大红袍 -- 发布时间:2016/2/18 9:45:00 -- DataTables("表A").Find("其余条件 And _Identify < " & 当前行("_Identify")) |
-- 作者:dixiaxiaodan -- 发布时间:2016/2/18 9:47:00 -- 谢谢! |
-- 作者:dixiaxiaodan -- 发布时间:2016/2/18 9:57:00 -- 以下是引用大红袍在2016/2/18 9:45:00的发言: 红袍哥,我设置查找范围的目的是因为数据量太大,全部查找程序会卡。用你这种方法的话,是不是仍会全部遍历一遍啊
DataTables("表A").Find("其余条件 And _Identify < " & 当前行("_Identify")) |
-- 作者:大红袍 -- 发布时间:2016/2/18 9:59:00 -- 你全部代码肯定有问题,看完这一章
http://www.foxtable.com/help/topics/2226.htm
|
-- 作者:dixiaxiaodan -- 发布时间:2016/2/18 10:09:00 -- 我代码还是挺简单的,就是数据量大了一些,您看看 If e.DataCol.Name = "章节号" Then \'如果更改的是章节号列 If e.DataRow.IsNull("日期") And e.DataRow.IsNull("系统章节") Then \'日期和系统章节列是否为空 e.DataRow("预警") = "信息不足" \'如果为空 ElseIf e.DataRow("校准后") = "MAINT" Or e.DataRow("校准后") = "PILOT" Then Dim Dr_Repeatability = DataTables("故障报告").Find("日期 >= #" & e.DataRow("日期").AddDays(-30) & "# and 日期 <= #" & e.DataRow("日期") & "# and 系统章节 = \'" & e.DataRow("系统章节") & "\' and 飞机号 = \'" & e.DataRow("飞机号") & "\'","日期 Desc",2) \'查找重复性故障 If Dr_Repeatability IsNot Nothing Then e.DataRow("预警") = "重复性故障" Else e.DataRow("预警") = "正常" End If End If End If 但是数据量一大,就会卡,我就想能不能设定一下find的查找范围 |
-- 作者:dixiaxiaodan -- 发布时间:2016/2/18 10:14:00 -- 以下是引用dixiaxiaodan在2016/2/18 10:09:00的发言: 对了,正常输入的时候是不卡的,但是点击重置列时会卡到三分钟左右
我代码还是挺简单的,就是数据量大了一些,您看看 If e.DataCol.Name = "章节号" Then \'如果更改的是章节号列 If e.DataRow.IsNull("日期") And e.DataRow.IsNull("系统章节") Then \'日期和系统章节列是否为空 e.DataRow("预警") = "信息不足" \'如果为空 ElseIf e.DataRow("校准后") = "MAINT" Or e.DataRow("校准后") = "PILOT" Then Dim Dr_Repeatability = DataTables("故障报告").Find("日期 >= #" & e.DataRow("日期").AddDays(-30) & "# and 日期 <= #" & e.DataRow("日期") & "# and 系统章节 = \'" & e.DataRow("系统章节") & "\' and 飞机号 = \'" & e.DataRow("飞机号") & "\'","日期 Desc",2) \'查找重复性故障 If Dr_Repeatability IsNot Nothing Then e.DataRow("预警") = "重复性故障" Else e.DataRow("预警") = "正常" End If End If End If 但是数据量一大,就会卡,我就想能不能设定一下find的查找范围 |
-- 作者:大红袍 -- 发布时间:2016/2/18 10:22:00 -- 数据量越大,find的次数越多,肯定越慢。而且那你还有日期的比较 http://www.foxtable.com/help/topics/2219.htm
你可以单独做一个按钮,尽量不要用find看是否可以。 |
-- 作者:dixiaxiaodan -- 发布时间:2016/2/18 13:45:00 -- 以下是引用大红袍在2016/2/18 10:22:00的发言: 谢谢红袍哥了,现在才改完,改成下面的代码速度飞起了数据量越大,find的次数越多,肯定越慢。而且那你还有日期的比较 http://www.foxtable.com/help/topics/2219.htm
你可以单独做一个按钮,尽量不要用find看是否可以。 Dim drs1 As List(Of DataRow) Dim drs2 As List(Of DataRow) drs1 = DataTables("故障报告2").Select("" & Filter & "") For Each dr1 As DataRow In drs1 Dim dv As Date = dr1("日期") Dim n As Integer = 0 drs2 = DataTables("故障报告2").Select("飞机号 = \'" & dr1("飞机号") & "\' and 系统章节 = \'" & dr1("系统章节") & "\'", "日期") \'注意要根据日期排序 For Each dr2 As DataRow In drs2 \'dr2("预警") = Nothing If dr2("日期") >= dv.AddDays(-30) And dr2("日期") < dv.AddDays(0) Then n = n + 1 If n >=2 Then dr1("自定义预警") = "重复性故障" End If Else Exit For End If Next Next |
-- 作者:dixiaxiaodan -- 发布时间:2016/2/18 15:06:00 -- 以下是引用大红袍在2016/2/18 10:22:00的发言: 数据量越大,find的次数越多,肯定越慢。而且那你还有日期的比较 http://www.foxtable.com/help/topics/2219.htm
你可以单独做一个按钮,尽量不要用find看是否可以。 我写的代码是分别根据章节号的前两位和四位进行预警,按理说,四位预警的情况下,两位章节一定会发生预警才对,麻烦红袍哥帮忙看下,我这公司内网,没法上传附件,传代码了啊。 系统章节 = 章节号的前两位 章节号共四位 \'\'\'-----------------------------------两位章节预警-------------------------------------------------------------\'\' If e.DataCol.Name = "日期" Then Dim drs As List(of DataRow) Dim dv As Date = e.DataRow("日期") Dim n As Integer = 0 drs = DataTables("故障报告2").Select("飞机号 = \'" & e.DataRow("飞机号") & "\' and 系统章节 = \'" & e.DataRow("系统章节") & "\'", "日期") \'注意要根据日期排序 For Each dr2 As DataRow In drs \'dr2("预警") = Nothing If dr2("日期") >= dv.AddDays(-30) And dr2("日期") < dv Then n = n + 1 If n >=2 Then e.DataRow("预警") = "重复性故障" End If Else Exit For End If Next End If \'\'\'-----------------------------------四位章节预警-------------------------------------------------------------\'\' If e.DataCol.Name = "日期" Then Dim drs As List(of DataRow) Dim dv As Date = e.DataRow("日期") Dim n As Integer = 0 drs = DataTables("故障报告2").Select("飞机号 = \'" & e.DataRow("飞机号") & "\' and 章节号 = \'" & e.DataRow("章节号") & "\'", "日期") \'注意要根据日期排序 For Each dr2 As DataRow In drs If dr2("日期") >= dv.AddDays(-30) And dr2("日期") < dv Then n = n + 1 If n >=2 Then e.DataRow("四位章节预警") = "重复性故障" End If Else Exit For End If Next End If [此贴子已经被作者于2016/2/18 15:06:41编辑过]
|