2013-03-23 39 views
0

我想通過VB代碼中的標籤名稱獲取元素,就像我曾經在VBA中那樣,但無法弄清楚如何。我打開了一個新的瀏覽器窗口,然後代碼就卡住了。無法通過VB中的TagName獲取HTML元素

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

的問題,通過加入

Imports mshtml 

在代碼的頂部解決。