我试图通过我在VB代码中的标记名称来获取元素,就像我以前在VBA中一样,但是无法弄清楚如何。我打开一个新的浏览器窗口,但从那时起代码就被卡住了。
Public ie As New SHDocVw.InternetExplorer
Private Sub TEST(sender As Object, e As EventArgs) Handles MyBase.Load
Dim Keyword As Long
ie = New SHDocVw.InternetExplorer
ie.Visible = True
ie.Navigate("http://google.com/")
Do Until ie.ReadyState = SHDocVw.tagREADYSTATE.READYSTATE_COMPLETE
Application.DoEvents()
Loop
Dim Doc As HtmlDocument
Doc = ie.Document
Keyword = Doc.GetElementsByTagName("td")(8).InnerText
MsgBox(Keyword)
End Sub
答案 0 :(得分:0)
通过添加
解决了这个问题Imports mshtml
代码顶部。