by Brogan Scott Houston McIntyre (2 Submissions)
Category: Internet/HTML
Compatability: Visual Basic 5.0
Difficulty: Beginner
Date Added: Wed 3rd February 2021
Rating: (5 Votes)
Navigate a web browser control and wait for it to finish loading before going on to the next lines of code!
Assumes
You simply need to have a Web Browser control on your form and add this sample code.
'This is the NavigateAndWait sub.
'rURL is the hyperlink that you want the web browser control to navigate to.
'rWebBrowser is the web browser control that you would like to use.
Public Sub NavigateAndWait(rURL As String, rWebBrowser As Control)
rWebBrowser.Navigate rURL 'Navigate to any URL.
Do Until rWebBrowser.ReadyState = READYSTATE_COMPLETE 'Loop until the web browser control is ready.
DoEvents 'This will stop the program from locking up while waiting, and allow other code to continue processing.
Loop
End Sub
Private Sub Command1_Click() 'This is an example button.
NavigateAndWait "http://www.Planet-Source-Code.com", Me.WebBrowser1 'This is an example on how to call the NavigateAndWait sub.
MsgBox "Loaded!" 'This is a message box to alert you that the page has been loaded. This line is not required.
End Sub