以文本方式查看主题
- Foxtable(狐表) (http://www.foxtable.com/bbs/index.asp)
-- 专家坐堂 (http://www.foxtable.com/bbs/list.asp?boardid=2)
---- 老师,通过for each 集合 去修改这个集合要怎么做? (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=110296)
|
-- 作者:rxfmrqq
-- 发布时间:2017/11/30 15:23:00
-- 老师,通过for each 集合 去修改这个集合要怎么做?
For Each dr2 As DataRow In drs For Each tx As String In txm If dr2.lines("药品类别").Contains(tx) = False Then drs.Remove(dr2) Exit For End If Next Next
运行到这段就提示集合已修改。
|
-- 作者:有点蓝
-- 发布时间:2017/11/30 16:16:00
--
没看懂要做什么。完整代码发上来,再描述具体要做什么
|
-- 作者:rxfmrqq
-- 发布时间:2017/11/30 16:32:00
--
Dim i As Integer Dim lb As new List(of String) Dim drs As new List(of DataRow) If e.Form.Controls("TextBox1").text = "" Then e.Form.Controls("TextBox1").text = e.sender.text Else e.Form.Controls("TextBox1").text = e.Form.Controls("TextBox1").text & vbcrlf & e.sender.text End If For i = 1 To 15 e.Form.Controls("" & i & "").text = "" Next Dim txm As new List(of String) If e.Form.Controls("GroupBox1").text = "选择药品属性" Then For Each tx As String In e.Form.Controls("TextBox1").lines txm.add(tx) Next For Each dr As DataRow In DataTables("兽药品种库").DataRows If dr.lines("药品类别").contains(txm(0))= True Then drs.add(dr) End If Next If txm.count > 1 Then For i = drs.count-1 To 0 Step -1 For Each tx As String In txm If drs(i).lines("药品类别").Contains(tx) = False Then drs.Removeat(i) End If Next Next End If For Each dr3 As DataRow In drs For Each drm As String In dr3.lines("药品类别") If txm.contains(drm) = False AndAlso lb.contains(drm) = False Then lb.add(drm) End If Next Next
额就是一个递进 的 find 选项。 但是我的 row 的内容是分行的。
|
-- 作者:有点蓝
-- 发布时间:2017/11/30 17:12:00
--
If txm.count > 1 Then For i = drs.count-1 To 0 Step -1 For Each tx As String In txm If drs(i).lines("药品类别").Contains(tx) = False Then drs.Removeat(i)exit for End If Next Next End If
[此贴子已经被作者于2017/11/30 17:12:29编辑过]
|