/ / VB.net InternetExplorer HtmlDocument - vb.net

VB.net InternetExplorer HtmlDocument - vb.net

¿Alguien me puede ayudar? Soy nuevo en VB.net e intento escribir un código muy simple para manipular un sitio web. Sin embargo, sigo recibiendo

"Una excepción no controlada de tipo" Sistema.InvalidCastException "ocurrió en Defer All.exe .... No se puede convertir el objeto COM de tipo "System .__ ComObject" para el tipo de interfaz "mshtml.HTMLDocument". Esta operación fallida porque la llamada a QueryInterface en el componente COM para la interfaz con 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

Respuestas

1 para la respuesta № 1

cambio...

Dim IE As InternetExplorer
Dim HTMLDoc As HtmlDocument
"                    ^---------------------------this thing to,
mshtml.IHTMLDocument
Dim oHTML_Element As mshtml.IHTMLElement