以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 请教代码 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=73614) |
-- 作者:hbhb -- 发布时间:2015/8/23 10:21:00 -- 请教代码 大师:请教删除任意四列为空的行,简易代码? |
-- 作者:大红袍 -- 发布时间:2015/8/23 11:29:00 -- For i As Integer = DataTables("表A").datarows.Count - 1 To 0 Step -1 Dim dr As DataRow = DataTables("表A").datarows(i) Dim count As Integer = 0 For Each dc As DataCol In DataTables("表A").DataCols If dr.IsNull(dc.Name) Then count += 1 Next If count >= 4 Then dr.delete End If Next |
-- 作者:hbhb -- 发布时间:2015/8/23 11:39:00 -- 谢谢!我这样写对不对?为何您写的代码就是比我高效精简。原因在哪? Dim n As Integer Dim hjh As new List(of Row) hjh.Clear For Each r As Row In Tables("表a").Rows For Each l As Col In Tables("表a").Cols If r.IsNull(l.name) Then n = n + 1 End If Next if n >= 4 then hjh.add(r) n = 0 Next For Each r As Row In hjh r.Delete Next |
-- 作者:大红袍 -- 发布时间:2015/8/23 11:42:00 -- 都行,差不多 |