我已经在vba中编写了一个脚本,以打印由PrintResult()
函数填充的子过程getPOST()
中的所有结果。我当前的尝试是仅打印已解析内容的最后结果。我知道有可能将结果存储在字典中以便一次打印所有内容,但无法了解这种特定用法。
重要的是要保持现有设计的完整性。
当前尝试:
Function getPOST() As String
Const link$ = "https://admintool.noah-connect.com/widget/attendees"
Dim Http As New XMLHTTP60, Html As New HTMLDocument
Dim elem As Object, tRow As Object, oName As Object, oCom As Object
With Http
.Open "GET", link, False
.send
Html.body.innerHTML = .responseText
For Each elem In Html.getElementsByTagName("tbody")(0).getElementsByTagName("tr")
Set oName = elem.getElementsByTagName("td")(0)
Set oCom = elem.getElementsByTagName("td")(1)
getPOST = oName.innerText & "-" & oCom.innerText
Next elem
End With
End Function
Sub PrintResult()
Debug.Print getPOST()
End Sub
如何在PrintResult()
函数填充的getPOST()
中打印所有结果?
答案 0 :(得分:1)
不确定保留设计是什么意思,因此请提供字符串返回和字典 (作为对象)返回方法
(1)This section applies if—(a)before the commencement—(i)a person applied under section 28(1) of the repealed regulation for approval of a proposed fire engineering design brief for stated building work; and
(ii)an authorised representative of the service attended a former fire engineering brief meeting relating to the approval of the proposed fire engineering design brief; and
(iii)the service had not decided whether or not to approve the proposed fire engineering design brief; and
(b)the person has not paid the former fire engineering design brief meeting fee for the attendance of the representative of the service at the former fire engineering brief meeting.
(2)For assessing the fire engineering design brief for the stated building work—(a)section 61 applies as if the reference to a fire engineering brief were a reference to the proposed fire engineering design brief; and
(b)section 62(1)(d) applies as if the reference to each fire engineering brief meeting included a reference to each former fire engineering brief meeting; and
(c)schedule 2, part 3, item 3 applies as if a reference to a meeting included a reference to a former fire engineering brief meeting.
(3)In this section—former fire engineering brief meeting means a fire engineering brief meeting under section 28(2)(d) of the repealed regulation.former fire engineering design brief meeting fee means the fire engineering design brief meeting fee stated in schedule 3 of the repealed regulation.
Option Explicit
Public Sub PrintResult()
Dim dict As Object, key As Variant
Set dict = getPOST
For Each key In dict.keys
Debug.Print dict(key)
Next
End Sub
Public Function getPOST() As Object
Const link$ = "https://admintool.noah-connect.com/widget/attendees"
Dim http As New XMLHTTP60, html As New HTMLDocument
Dim elem As Object, tRow As Object, oName As Object, oCom As Object
Dim i As Long, dict As Object
Set dict = CreateObject("Scripting.Dictionary")
With http
.Open "GET", link, False
.send
html.body.innerHTML = .responseText
For Each elem In html.getElementsByTagName("tbody")(0).getElementsByTagName("tr")
i = i + 1
Set oName = elem.getElementsByTagName("td")(0)
Set oCom = elem.getElementsByTagName("td")(1)
dict(i) = oName.innerText & "-" & oCom.innerText
Next elem
End With
Set getPOST = dict
End Function