誰か助けてくれますか?私はVB.netを初めて使い、ウェブサイトを操作するための非常に簡単なコードを書くようにしています。しかし、私は続ける
msgstr "未処理の型の例外"システム。InvalidCastException "が発生しました in Defer All.exe ....型のCOMオブジェクトをキャストできません "System .__ ComObject"をインタフェースタイプ "mshtml.HTMLDocument"に変換します。この COMコンポーネントのQueryInterface呼び出しが原因で操作が失敗しました 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
回答:
回答№1は1変化する...
Dim IE As InternetExplorer
Dim HTMLDoc As HtmlDocument
" ^---------------------------this thing to,
mshtml.IHTMLDocument
Dim oHTML_Element As mshtml.IHTMLElement