net5

 

Run Internet Explorer And Have The Events Return To Your Program


Run Internet Explorer And Have The Events Return To Your Program

You can run an instance of Internet Explorer, and have the events return
to your program. An event is the text that appear in the Internet
Explorer status bar every time you do something, for example: "Connecting
to 154.121.100.23", "Done", "Opening page http://vbtown.cjb.net", and
more.


Preparations

Add 1 Label to your form. The events will be displayed in this label.

Add Reference to Microsoft Internet Controls (SHDOCVW.DLL).
To add the reference, choose from VB menu Project -> References... and
mark the Microsoft Internet Controls check box. Notice that it's possible
there are more than 1 Microsoft Internet Controls check boxes. To know
which is the right check box, mark it and look at the "Location: " at the
bottom of the window. You should see a path that ends with "\SHDOCVW.DLL".
Then press OK.


Form Code

Public WithEvents web As SHDocVw.InternetExplorer

Private Sub Form_Load()
' create new instance of Internet Explorer
Set web = New SHDocVw.InternetExplorer
' make the Internet Explorer visible
web.Visible = True
' navigate to http://vbtown.cjb.net URL
web.Navigate "http://vbtown.cjb.net"
End Sub

Private Sub web_StatusTextChange(ByVal Text As String)
' when the text in the status bar changes, update the Label
Label1.Caption = Text
End Sub