如何遍历一个集合把符合条件的数据到一个指定单元格中: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编辑过]
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"))
此主题相关图片如下:6666.png

老师下面这段代码出错了,错在哪里?
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
此主题相关图片如下:77.jpg

调试看是哪一句代码出错?
试试
If elem isnot nothing andalso elem.InnerText isnot nothing andalso elem.InnerText.trim() > "" Then
[此贴子已经被作者于2023/10/28 12:12:25编辑过]