有人能帮助我吗?我是VB.net的新手,并尝试编写一个非常简单的代码来操纵一个网站。但是,我一直在
“发生了'System.InvalidCastException'类型的未处理异常 在Defer All.exe ....无法转换类型的COM对象 'System .__ ComObject'到接口类型'mshtml.HTMLDocument'。这个 操作失败,因为QueryInterface调用COM组件 对于与IID'....)的接口。“
Dim IE As InternetExplorer
Dim HTMLDoc As HtmlDocument
Dim oHTML_Element As mshtml.IHTMLElement
IE = new InternetExplorer
IE.Navigate("http://www.mediafire.com/")
Do Until IE.ReadyState = 4
Loop
Loop Until Not IE.Busy
' ERROR on the following line
HTMLDoc = IE.Document
' I tried making HTMLDoc as object. It passed the above line, but failed the next line due to no GetElementsByTagName method
For Each oHTML_Element In HTMLDoc.GetElementsByTagName("input")
'....................
Next
答案 0 :(得分:1)
...变化
Dim IE As InternetExplorer
Dim HTMLDoc As HtmlDocument
' ^---------------------------this thing to,
mshtml.IHTMLDocument
Dim oHTML_Element As mshtml.IHTMLElement