以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  [求助] 代码优化  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=139099)

--  作者:susanhe
--  发布时间:2019/8/5 23:05:00
--  [求助] 代码优化

你好,请问下以下代码可不可以还能优化一下 ?

 

 


Dim drsr As List(Of DataRow) = DataTables("库存表").Select("Qty < 0")
For Each drd As DataRow In drsr
    Dim dr2d As DataRow = DataTables("待检产品").AddNew()
  For Each dcd As DataCol In DataTables("库存表").DataCols
        dr2d(dcd.Name) = drd(dcd.name)
    Next
    drd.Delete
Next


--  作者:y2287958
--  发布时间:2019/8/6 8:22:00
--  
已经最简了,除非结合实际改变思路
[此贴子已经被作者于2019/8/6 8:22:15编辑过]

--  作者:有点蓝
--  发布时间:2019/8/6 8:49:00
--  
Dim drsr As List(Of DataRow) = DataTables("库存表").Select("Qty < 0")
For i As Integer = drsr.Count - 1 To 0 Step -1
    Dim drd As DataRow = drsr(i)
    Dim dr2d As DataRow = DataTables("待检产品").AddNew()
    For Each dcd As DataCol In DataTables("库存表").DataCols
        dr2d(dcd.Name) = drd(dcd.name)
    Next
    drd.Delete
Next