Public Class Form1<br /> Private WithEvents IE As SHDocVw.InternetExplorer<br /> Private Doc As mshtml.HTMLDocument<br /> <br /> Private Sub IE_DocumentComplete(pDisp As Object, ByRef URL As Object) Handles IE.DocumentComplete<br /> Doc = IE.Document<br /> MsgBox(Doc.frames.length) ' **System.InvalidCastException error here**<br /> End Sub<br /> <br /> Private Sub main_Load(sender As Object, e As EventArgs) Handles MyBase.Load<br /> IE = New SHDocVw.InternetExplorer()<br /> IE.Visible = True<br /> <br /> IE.Navigate("https://www.google.co.jp")<br /> waitIE(IE)<br /> <br /> End Sub<br /> <br /> Private Sub waitIE(ByVal objIE As SHDocVw.InternetExplorer)<br /> Do Until objIE.ReadyState = SHDocVw.tagREADYSTATE.READYSTATE_COMPLETE Or objIE.Busy = False<br /> Application.DoEvents()<br /> 'System.Threading.Thread.Sleep(100)<br /> Loop<br /> <br /> Do While objIE.Document.ReadyState <> "complete"<br /> Application.DoEvents()<br /> Loop<br /> End Sub<br /> End Class
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)