以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- 如何遍历一个集合把符合条件的数据到一个指定单元格中 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=188743) |
-- 作者:ZJZK2018 -- 发布时间:2023/10/15 9:12:00 -- 如何遍历一个集合把符合条件的数据到一个指定单元格中 如何遍历一个集合把符合条件的数据到一个指定单元格中: Dim nms As New List(Of String) From {"杭州", "上海", "北京","宁波","金华"}
For Each nm As String In nms If nm.Contains (s) Then r("地区") = nm \'nm有多个值给一个单元格,并以换行形式出现 End If Next 效果如下: 杭州 上海 北京 绍兴 [此贴子已经被作者于2023/10/15 9:40:11编辑过]
|
-- 作者:ZJZK2018 -- 发布时间:2023/10/15 16:25:00 -- Dim nms As New List(Of String) From {"杭州", "上海"," ", "北京","宁波","金华"} Dim st As String = "" For Each nm As String In nms If nm > "" Then st &= nm & vbCrlf End If Next msgbox(st.Replace("vbCrlf & vbCrlf","vbCrlf")) |
-- 作者:有点蓝 -- 发布时间:2023/10/15 20:50:00 -- If nm.trim() > "" Then |
-- 作者:ZJZK2018 -- 发布时间:2023/10/15 21:03:00 -- 老师下面这段代码出错了,错在哪里? For Each r As Row In Tables("招标公告").Rows Dim blwz As String = r("公告网址") Dim web As New System.Windows.Forms.WebBrowser() web.ScriptErrorsSuppressed = True \'解决网页页面的脚本错误提示 web.Navigate(blwz) Do Until web.ReadyState = 4 AndAlso web.Document.GetElementById("zoom") IsNot Nothing \'用ID确定属性内容 Application.DoEvents \'绘制控件的代码即刻生效 Loop \'\'\'---------- Dim elems As object elems = web.Document.GetElementById("zoom").GetElementsByTagName("P") Dim st As String = "" For Each elem As System.Windows.Forms.HtmlElement In elems If elem.InnerText.trim() > "" Then st &= elem.InnerText & vbCrLf End If Next r("招标公告") = st Next |
-- 作者:有点蓝 -- 发布时间:2023/10/15 21:14:00 -- 调试看是哪一句代码出错? 试试 If elem isnot nothing andalso elem.InnerText isnot nothing andalso elem.InnerText.trim() > "" Then
|
-- 作者:ZJZK2018 -- 发布时间:2023/10/15 21:36:00 -- 谢谢 |
-- 作者:ZJZK2018 -- 发布时间:2023/10/28 12:06:00 -- [此贴子已经被作者于2023/10/28 12:12:25编辑过]
|