以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  [讨论]移除集合lines中的值  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=138274)

--  作者:天一生水
--  发布时间:2019/7/26 19:27:00
--  [讨论]移除集合lines中的值
移除单元格多行文本中包含特定字符的行,报如图错误:

Dim lst As New List(of String)
lst = Tables("表A").Current.DataRow.Lines("第一列")
For Each ls As String In lst
    If ls.Contains("A") = True Then
        lst.Remove(ls)
    End If
Next

Tables("表A").Current.DataRow.Lines("第一列") = lst


图片点击可在新窗口打开查看此主题相关图片如下:截屏图片 (1).jpg
图片点击可在新窗口打开查看


--  作者:有点蓝
--  发布时间:2019/7/26 21:06:00
--  
凡是集合遍历删除都需要倒序处理

Dim lst As New List(of String)
lst = Tables("表A").Current.DataRow.Lines("第一列")
for i as integer = lst.count - 1 to  0 step -1
    If lst(i).Contains("A") = True Then
        lst.Removeat(i)
    End If
Next